[llvm] [X86] emitEpilogue - silence implicit integer extension warning. (PR #127185)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 01:11:48 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Simon Pilgrim (RKSimon)

<details>
<summary>Changes</summary>

Silence compiler warning introduced in #<!-- -->125007 - assign the address delta to int64_t, assert it is negative and negate it only as part of the mergeSPAdd call

Fixes #<!-- -->125825

---
Full diff: https://github.com/llvm/llvm-project/pull/127185.diff


1 Files Affected:

- (modified) llvm/lib/Target/X86/X86FrameLowering.cpp (+4-4) 


``````````diff
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 50c56c9dd08b3..10fb6994b51b6 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -2639,11 +2639,11 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
 
   if (Terminator == MBB.end() || !isTailCallOpcode(Terminator->getOpcode())) {
     // Add the return addr area delta back since we are not tail calling.
-    int64_t Offset = -1 * X86FI->getTCReturnAddrDelta();
-    assert(Offset >= 0 && "TCDelta should never be positive");
-    if (Offset) {
+    int64_t Delta = X86FI->getTCReturnAddrDelta();
+    assert(Delta <= 0 && "TCDelta should never be positive");
+    if (Delta) {
       // Check for possible merge with preceding ADD instruction.
-      Offset = mergeSPAdd(MBB, Terminator, Offset, true);
+      int64_t Offset = mergeSPAdd(MBB, Terminator, -Delta, true);
       emitSPUpdate(MBB, Terminator, DL, Offset, /*InEpilogue=*/true);
     }
   }

``````````

</details>


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


More information about the llvm-commits mailing list