@@ -435,17 +435,11 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
435435 return ;
436436 }
437437
438- bool HasAllocaOrASCast = false ;
439- for (BasicBlock &BB : *F) {
440- for (Instruction &I : BB) {
441- if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
442- HasAllocaOrASCast = true ;
443- removeAssumedBits (FLAT_SCRATCH_INIT);
444- break ;
445- }
438+ for (Instruction &I : instructions (F)) {
439+ if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
440+ removeAssumedBits (FLAT_SCRATCH_INIT);
441+ return ;
446442 }
447- if (HasAllocaOrASCast)
448- break ;
449443 }
450444 }
451445
@@ -702,13 +696,12 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
702696 // no-flat-scratch-init.
703697 auto CheckForNoFlatScratchInit = [&](Instruction &I) {
704698 const auto &CB = cast<CallBase>(I);
705- const Value *CalleeOp = CB.getCalledOperand ();
706- const Function *Callee = dyn_cast<Function>(CalleeOp);
699+ const Function *Callee = CB.getCalledFunction ();
707700 if (!Callee) // indirect call
708701 return CB.isInlineAsm ();
709702
710703 if (Callee->isIntrinsic ())
711- return true ;
704+ return Callee-> getIntrinsicID () != Intrinsic::amdgcn_addrspacecast_nonnull ;
712705
713706 const auto *CalleeInfo = A.getAAFor <AAAMDAttributes>(
714707 *this , IRPosition::function (*Callee), DepClassTy::REQUIRED);
@@ -717,7 +710,8 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
717710
718711 bool UsedAssumedInformation = false ;
719712 // If any callee is false (i.e. need FlatScratchInit),
720- // checkForAllCallLikeInstructions returns false
713+ // checkForAllCallLikeInstructions returns false, in which case this
714+ // function returns true.
721715 return !A.checkForAllCallLikeInstructions (CheckForNoFlatScratchInit, *this ,
722716 UsedAssumedInformation);
723717 }
0 commit comments