[llvm] Fix stack temporary leaks for indirect arguments (PR #213134)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 13:48:27 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/CodeGen/StackColoring.cpp llvm/lib/Target/X86/X86ISelLoweringCall.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index 8902f560d..0352f4f0b 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -952,10 +952,10 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
 
       // AA might be used later for instruction scheduling, and we need it to be
       // able to deduce the correct aliasing releationships between pointers
-      // derived from the alloca being remapped and the target of that remapping.
-      // The only safe way, without directly informing AA about the remapping
-      // somehow, is to directly update the IR to reflect the change being made
-      // here.
+      // derived from the alloca being remapped and the target of that
+      // remapping. The only safe way, without directly informing AA about the
+      // remapping somehow, is to directly update the IR to reflect the change
+      // being made here.
       Instruction *Inst = const_cast<AllocaInst *>(To);
       if (From->getType() != To->getType()) {
         BitCastInst *Cast = new BitCastInst(Inst, From->getType());
@@ -971,15 +971,16 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
       // variable, so poison out the use to make the verifier happy.
       AllocaInst *FromAI = const_cast<AllocaInst *>(From);
       if (FromAI->isUsedByMetadata())
-        ValueAsMetadata::handleRAUW(FromAI, PoisonValue::get(FromAI->getType()));
+        ValueAsMetadata::handleRAUW(FromAI,
+                                    PoisonValue::get(FromAI->getType()));
       for (auto &Use : FromAI->uses()) {
         if (BitCastInst *BCI = dyn_cast<BitCastInst>(Use.get()))
           if (BCI->isUsedByMetadata())
             ValueAsMetadata::handleRAUW(BCI, PoisonValue::get(BCI->getType()));
       }
 
-      // Note that this will not replace uses in MMOs (which we'll update below),
-      // or anywhere else (which is why we won't delete the original
+      // Note that this will not replace uses in MMOs (which we'll update
+      // below), or anywhere else (which is why we won't delete the original
       // instruction).
       FromAI->replaceAllUsesWith(Inst);
     }
diff --git a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
index bf6daa03d..019002237 100644
--- a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
+++ b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
@@ -2372,14 +2372,13 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
         // as guaranteed by the `byval` attribute.
         uint64_t Size = Flags.getByValSize();
         int FrameIdx = MF.getFrameInfo().CreateStackObject(
-            Size,
-            std::max(Align(16), Flags.getNonZeroByValAlign()), false);
+            Size, std::max(Align(16), Flags.getNonZeroByValAlign()), false);
         CallTemporaries.push_back(FrameIdx);
         SetupChain = DAG.getLifetimeNode(true, dl, Chain, FrameIdx);
         SDValue StackSlot =
             DAG.getFrameIndex(FrameIdx, getPointerTy(DAG.getDataLayout()));
-        SetupChain =
-            CreateCopyOfByValArgument(Arg, StackSlot, SetupChain, Flags, DAG, dl);
+        SetupChain = CreateCopyOfByValArgument(Arg, StackSlot, SetupChain,
+                                               Flags, DAG, dl);
         // From now on treat this as a regular pointer
         Arg = StackSlot;
         isByVal = false;
@@ -2797,8 +2796,8 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 
   // Handle result values, copying them out of physregs into vregs that we
   // return.
-  SDValue ResChain = LowerCallResult(Chain, InGlue, CallConv, isVarArg, Ins, dl, DAG,
-                                     InVals, RegMask);
+  SDValue ResChain = LowerCallResult(Chain, InGlue, CallConv, isVarArg, Ins, dl,
+                                     DAG, InVals, RegMask);
   for (int FI : CallTemporaries) {
     ResChain = DAG.getLifetimeNode(false, dl, ResChain, FI);
   }

``````````

</details>


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


More information about the llvm-commits mailing list