@@ -435,17 +435,11 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
435
435
return ;
436
436
}
437
437
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 ;
446
442
}
447
- if (HasAllocaOrASCast)
448
- break ;
449
443
}
450
444
}
451
445
@@ -702,13 +696,12 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
702
696
// no-flat-scratch-init.
703
697
auto CheckForNoFlatScratchInit = [&](Instruction &I) {
704
698
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 ();
707
700
if (!Callee) // indirect call
708
701
return CB.isInlineAsm ();
709
702
710
703
if (Callee->isIntrinsic ())
711
- return true ;
704
+ return Callee-> getIntrinsicID () != Intrinsic::amdgcn_addrspacecast_nonnull ;
712
705
713
706
const auto *CalleeInfo = A.getAAFor <AAAMDAttributes>(
714
707
*this , IRPosition::function (*Callee), DepClassTy::REQUIRED);
@@ -717,7 +710,8 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
717
710
718
711
bool UsedAssumedInformation = false ;
719
712
// 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.
721
715
return !A.checkForAllCallLikeInstructions (CheckForNoFlatScratchInit, *this ,
722
716
UsedAssumedInformation);
723
717
}
0 commit comments