@@ -692,20 +692,23 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
692692 // Returns true if FlatScratchInit is needed, i.e., no-flat-scratch-init is
693693 // not to be set.
694694 bool needFlatScratchInit (Attributor &A) {
695+ assert (isAssumed (FLAT_SCRATCH_INIT)); // only called if the bit is still set
696+
695697 // This is called on each callee; false means callee shouldn't have
696698 // no-flat-scratch-init.
697699 auto CheckForNoFlatScratchInit = [&](Instruction &I) {
698700 const auto &CB = cast<CallBase>(I);
699701 const Function *Callee = CB.getCalledFunction ();
700- if (!Callee) // indirect call
701- return CB.isInlineAsm ();
702702
703- if (Callee->isIntrinsic ())
704- return Callee->getIntrinsicID () != Intrinsic::amdgcn_addrspacecast_nonnull;
703+ if (Callee && Callee->isIntrinsic ())
704+ return Callee->getIntrinsicID () !=
705+ Intrinsic::amdgcn_addrspacecast_nonnull;
705706
706- const auto *CalleeInfo = A.getAAFor <AAAMDAttributes>(
707- *this , IRPosition::function (*Callee), DepClassTy::REQUIRED);
708- return CalleeInfo && CalleeInfo->isAssumed (FLAT_SCRATCH_INIT);
707+ // Return true for all other cases, including (1)inline asm, (2)direct
708+ // call, and (3)indirect call with known callees. For (2) and (3)
709+ // updateImpl() already checked the callees and we know their
710+ // FLAT_SCRATCH_INIT bit is set.
711+ return true ;
709712 };
710713
711714 bool UsedAssumedInformation = false ;
0 commit comments