[llvm] Fix SIFixSGPRCopies To Handle Physical Registers (PR #149859)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 03:11:34 PDT 2025


================
@@ -256,17 +256,18 @@ AMDGPUResourceUsageAnalysisImpl::analyzeResourceUsage(
 
         const Function *Callee = getCalleeFunction(*CalleeOp);
 
+        auto isSameFunction = [](const MachineFunction &MF, const Function *F) {
+          return F == &MF.getFunction();
+        };
+
         // Avoid crashing on undefined behavior with an illegal call to a
         // kernel. If a callsite's calling convention doesn't match the
         // function's, it's undefined behavior. If the callsite calling
         // convention does match, that would have errored earlier.
-        if (Callee && AMDGPU::isEntryFunctionCC(Callee->getCallingConv()))
+        if (Callee && AMDGPU::isEntryFunctionCC(Callee->getCallingConv()) &&
+            !isSameFunction(MF, Callee))
           report_fatal_error("invalid call to entry function");
----------------
JanekvO wrote:

Sorry, I may be missing something but why is this error message being constrained?
Or, to phrase it differently, why are self-recursive (entry) functions allowed beyond this error now?
Also, is there a test case that showcases this? If this change to ResourceUsageAnalysis is worth it, it may be better off in its own PR

https://github.com/llvm/llvm-project/pull/149859


More information about the llvm-commits mailing list