[llvm] [AMDGPU] Infer amdgpu-no-flat-scratch-init attribute in AMDGPUAttributor (PR #94647)
Jun Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 11:02:29 PDT 2024
================
@@ -677,6 +693,33 @@ 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) {
+ // 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 Value *CalleeOp = CB.getCalledOperand();
+ const Function *Callee = dyn_cast<Function>(CalleeOp);
+ if (!Callee) // indirect call
+ return CB.isInlineAsm();
----------------
jwanggit86 wrote:
@ssahasra I fully agree with your description of how it works if `checkForAllCallees()` is used. Based on this, I'm not sure I see the advantage of using `checkForAllCallees()`. I think you still need to check all call-like instructions, and all it does is to move the real work (check for intrinsics, indirect calls etc) to this CallSite attribute. Furthermore, don't you need both a CallSite attribute and a Function attribute, because when you set up the CallSite attribute you need to retrieve some attribute from the callee? Besides, I want to mention that I was not able to find any use of `checkForAllCallees()` or any definition of CallSite attributes in the existing code.
@arsenm @jdoerfert Your thoughts?
https://github.com/llvm/llvm-project/pull/94647
More information about the llvm-commits
mailing list