@@ -434,17 +434,11 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
434434 return ;
435435 }
436436
437- bool HasAllocaOrASCast = false ;
438- for (BasicBlock &BB : *F) {
439- for (Instruction &I : BB) {
440- if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
441- HasAllocaOrASCast = true ;
442- removeAssumedBits (FLAT_SCRATCH_INIT);
443- break ;
444- }
437+ for (Instruction &I : instructions (F)) {
438+ if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
439+ removeAssumedBits (FLAT_SCRATCH_INIT);
440+ return ;
445441 }
446- if (HasAllocaOrASCast)
447- break ;
448442 }
449443 }
450444
@@ -701,13 +695,12 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
701695 // no-flat-scratch-init.
702696 auto CheckForNoFlatScratchInit = [&](Instruction &I) {
703697 const auto &CB = cast<CallBase>(I);
704- const Value *CalleeOp = CB.getCalledOperand ();
705- const Function *Callee = dyn_cast<Function>(CalleeOp);
698+ const Function *Callee = CB.getCalledFunction ();
706699 if (!Callee) // indirect call
707700 return CB.isInlineAsm ();
708701
709702 if (Callee->isIntrinsic ())
710- return true ;
703+ return Callee-> getIntrinsicID () != Intrinsic::amdgcn_addrspacecast_nonnull ;
711704
712705 const auto *CalleeInfo = A.getAAFor <AAAMDAttributes>(
713706 *this , IRPosition::function (*Callee), DepClassTy::REQUIRED);
@@ -716,7 +709,8 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
716709
717710 bool UsedAssumedInformation = false ;
718711 // If any callee is false (i.e. need FlatScratchInit),
719- // checkForAllCallLikeInstructions returns false
712+ // checkForAllCallLikeInstructions returns false, in which case this
713+ // function returns true.
720714 return !A.checkForAllCallLikeInstructions (CheckForNoFlatScratchInit, *this ,
721715 UsedAssumedInformation);
722716 }
0 commit comments