@@ -10743,22 +10743,6 @@ SDValue SystemZTargetLowering::lowerVECREDUCE_ADD(SDValue Op,
1074310743 DAG.getConstant (OpVT.getVectorNumElements () - 1 , DL, MVT::i32 ));
1074410744}
1074510745
10746- // Only consider a function fully internal as long as it has local linkage
10747- // and is not used in any other way than acting as the called function at
10748- // call sites.
10749- bool SystemZTargetLowering::isFullyInternal (const Function *Fn) const {
10750- if (!Fn->hasLocalLinkage ())
10751- return false ;
10752- for (const User *U : Fn->users ()) {
10753- if (auto *CB = dyn_cast<CallBase>(U)) {
10754- if (CB->getCalledFunction () != Fn)
10755- return false ;
10756- } else
10757- return false ;
10758- }
10759- return true ;
10760- }
10761-
1076210746static void printFunctionArgExts (const Function *F, raw_fd_ostream &OS) {
1076310747 FunctionType *FT = F->getFunctionType ();
1076410748 const AttributeList &Attrs = F->getAttributes ();
@@ -10777,6 +10761,16 @@ static void printFunctionArgExts(const Function *F, raw_fd_ostream &OS) {
1077710761 OS << " )\n " ;
1077810762}
1077910763
10764+ bool SystemZTargetLowering::isInternal (const Function *Fn) const {
10765+ std::map<const Function *, bool >::iterator Itr = IsInternalCache.find (Fn);
10766+ if (Itr == IsInternalCache.end ())
10767+ Itr = IsInternalCache
10768+ .insert (std::pair<const Function *, bool >(
10769+ Fn, (Fn->hasLocalLinkage () && !Fn->hasAddressTaken ())))
10770+ .first ;
10771+ return Itr->second ;
10772+ }
10773+
1078010774void SystemZTargetLowering::
1078110775verifyNarrowIntegerArgs_Call (const SmallVectorImpl<ISD::OutputArg> &Outs,
1078210776 const Function *F, SDValue Callee) const {
@@ -10789,8 +10783,8 @@ verifyNarrowIntegerArgs_Call(const SmallVectorImpl<ISD::OutputArg> &Outs,
1078910783 const Function *CalleeFn = nullptr ;
1079010784 if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee))
1079110785 if ((CalleeFn = dyn_cast<Function>(G->getGlobal ())))
10792- IsInternal = isFullyInternal (CalleeFn);
10793- if (!verifyNarrowIntegerArgs (Outs, IsInternal )) {
10786+ IsInternal = isInternal (CalleeFn);
10787+ if (!IsInternal && ! verifyNarrowIntegerArgs (Outs)) {
1079410788 errs () << " ERROR: Missing extension attribute of passed "
1079510789 << " value in call to function:\n " << " Callee: " ;
1079610790 if (CalleeFn != nullptr )
@@ -10811,7 +10805,7 @@ verifyNarrowIntegerArgs_Ret(const SmallVectorImpl<ISD::OutputArg> &Outs,
1081110805 if (!EnableIntArgExtCheck)
1081210806 return ;
1081310807
10814- if (!verifyNarrowIntegerArgs (Outs, isFullyInternal (F) )) {
10808+ if (!isInternal (F) && ! verifyNarrowIntegerArgs (Outs )) {
1081510809 errs () << " ERROR: Missing extension attribute of returned "
1081610810 << " value from function:\n " ;
1081710811 printFunctionArgExts (F, errs ());
@@ -10821,10 +10815,9 @@ verifyNarrowIntegerArgs_Ret(const SmallVectorImpl<ISD::OutputArg> &Outs,
1082110815
1082210816// Verify that narrow integer arguments are extended as required by the ABI.
1082310817// Return false if an error is found.
10824- bool SystemZTargetLowering::
10825- verifyNarrowIntegerArgs (const SmallVectorImpl<ISD::OutputArg> &Outs,
10826- bool IsInternal) const {
10827- if (IsInternal || !Subtarget.isTargetELF ())
10818+ bool SystemZTargetLowering::verifyNarrowIntegerArgs (
10819+ const SmallVectorImpl<ISD::OutputArg> &Outs) const {
10820+ if (!Subtarget.isTargetELF ())
1082810821 return true ;
1082910822
1083010823 if (EnableIntArgExtCheck.getNumOccurrences ()) {
0 commit comments