[llvm] [AArch64][GlobalISel] Fix incorrect ABI when tail call not supported (PR #70215)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 01:46:17 PDT 2023


================
@@ -854,7 +854,10 @@ bool AArch64CallLowering::areCalleeOutgoingArgsTailCallable(
 
   AArch64OutgoingValueAssigner CalleeAssigner(AssignFnFixed, AssignFnVarArg,
                                               Subtarget, /*IsReturn*/ false);
-  if (!determineAssignments(CalleeAssigner, OutArgs, OutInfo)) {
+  // determineAssignments() may modify argument flags, so make a copy.
+  SmallVector<ArgInfo, 8> OutArgsCopy;
+  append_range(OutArgsCopy, OutArgs);
+  if (!determineAssignments(CalleeAssigner, OutArgsCopy, OutInfo)) {
     LLVM_DEBUG(dbgs() << "... Could not analyze call operands.\n");
     return false;
   }
----------------
nikic wrote:

What I was referring to here is that OutInfo is used by further checks in this function. Though after your comment I saw that OutArgs is also used, so I've tweaked the code to make sure it gets the modified version, not the original one (I'm not sure whether this actually matters here, but better safe than sorry).

We don't need the result of determineAssignments() to persist outside this function (that is, the areCalleeOutgoingArgsTailCallable function). The actual tail call emission will call determineAssignments() again.

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


More information about the llvm-commits mailing list