[llvm] c693b9c - [MC] Fix double negation of DW_CFA_def_cfa_offset

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 22 20:03:19 PDT 2020


Author: Fangrui Song
Date: 2020-05-22T20:01:40-07:00
New Revision: c693b9c321d5a40d012340619674cf790c9ac86c

URL: https://github.com/llvm/llvm-project/commit/c693b9c321d5a40d012340619674cf790c9ac86c
DIFF: https://github.com/llvm/llvm-project/commit/c693b9c321d5a40d012340619674cf790c9ac86c.diff

LOG: [MC] Fix double negation of DW_CFA_def_cfa_offset

Negations are incorrectly added in two places and the code works just
because the negations cancel each other.

Added: 
    

Modified: 
    llvm/lib/MC/MCDwarf.cpp
    llvm/lib/MC/MCStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 48f585cf9499..d0fb77f62918 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1394,7 +1394,7 @@ void FrameEmitterImpl::emitCFIInstruction(const MCCFIInstruction &Instr) {
     if (IsRelative)
       CFAOffset += Instr.getOffset();
     else
-      CFAOffset = -Instr.getOffset();
+      CFAOffset = Instr.getOffset();
 
     Streamer.emitULEB128IntValue(CFAOffset);
 

diff  --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 356438c69ea5..5e24177274a6 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -472,7 +472,7 @@ void MCStreamer::emitCFIDefCfa(int64_t Register, int64_t Offset) {
 void MCStreamer::emitCFIDefCfaOffset(int64_t Offset) {
   MCSymbol *Label = emitCFILabel();
   MCCFIInstruction Instruction =
-      MCCFIInstruction::cfiDefCfaOffset(Label, -Offset);
+      MCCFIInstruction::cfiDefCfaOffset(Label, Offset);
   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
   if (!CurFrame)
     return;


        


More information about the llvm-commits mailing list