[llvm] [CFIInserter] Fix handling of OpRelOffset. (PR #126907)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 05:23:42 PST 2025


https://github.com/mgudim created https://github.com/llvm/llvm-project/pull/126907

The variable `SetOffset` holds the offset of CFA from CFA register. The cfi_rel_offset directive means we should add relative offset to `SetOffset`.

>From f616e8eaacb5dd9c04c8476dad00c21306a9c9a2 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at ventanamicro.com>
Date: Wed, 12 Feb 2025 05:15:32 -0800
Subject: [PATCH] [CFIInserter] Fix handling of OpRelOffset.

The variable `SetOffset` holds the offset of CFA from CFA register. The
cfi_rel_offset directive means we should add relative offset to
`SetOffset`.
---
 llvm/lib/CodeGen/CFIInstrInserter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/CFIInstrInserter.cpp b/llvm/lib/CodeGen/CFIInstrInserter.cpp
index be8393cd38674..5340aae6b2e57 100644
--- a/llvm/lib/CodeGen/CFIInstrInserter.cpp
+++ b/llvm/lib/CodeGen/CFIInstrInserter.cpp
@@ -217,7 +217,7 @@ void CFIInstrInserter::calculateOutgoingCFAInfo(MBBCFAInfo &MBBInfo) {
         CSRReg = CFI.getRegister2();
         break;
       case MCCFIInstruction::OpRelOffset:
-        CSROffset = CFI.getOffset() - SetOffset;
+        CSROffset = CFI.getOffset() + SetOffset;
         break;
       case MCCFIInstruction::OpRestore:
         CSRRestored.set(CFI.getRegister());



More information about the llvm-commits mailing list