[clang] [llvm] [AMDGPU] Infer amdgpu-no-flat-scratch-init attribute in AMDGPUAttributor (PR #94647)
Jun Wang via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 4 16:58:43 PDT 2024
================
@@ -677,6 +687,36 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
return !A.checkForAllCallLikeInstructions(DoesNotRetrieve, *this,
UsedAssumedInformation);
}
+
+ // Returns true if FlatScratchInit is needed, i.e., no-flat-scratch-init is
+ // not to be set.
+ bool needFlatScratchInit(Attributor &A) {
+ assert(isAssumed(FLAT_SCRATCH_INIT)); // only called if the bit is still set
+
+ // This is called on each callee; false means callee shouldn't have
+ // no-flat-scratch-init.
+ auto CheckForNoFlatScratchInit = [&](Instruction &I) {
+ const auto &CB = cast<CallBase>(I);
+ const Function *Callee = CB.getCalledFunction();
+
+ if (Callee && Callee->isIntrinsic())
+ return Callee->getIntrinsicID() !=
+ Intrinsic::amdgcn_addrspacecast_nonnull;
+
+ // Return true for all other cases, including (1)inline asm, (2)direct
+ // call, and (3)indirect call with known callees. For (2) and (3)
+ // updateImpl() already checked the callees and we know their
+ // FLAT_SCRATCH_INIT bit is set.
+ return true;
----------------
jwanggit86 wrote:
Improved a little.
https://github.com/llvm/llvm-project/pull/94647
More information about the cfe-commits
mailing list