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