[llvm] f9b14f0 - [MC] Report location information for MCDwarfCallFrameFragment diagnostics
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 18:02:26 PDT 2023
Author: Fangrui Song
Date: 2023-06-26T18:02:22-07:00
New Revision: f9b14f0b7cddd4c10d3fa6316ebb52fce2ad0e5b
URL: https://github.com/llvm/llvm-project/commit/f9b14f0b7cddd4c10d3fa6316ebb52fce2ad0e5b
DIFF: https://github.com/llvm/llvm-project/commit/f9b14f0b7cddd4c10d3fa6316ebb52fce2ad0e5b.diff
LOG: [MC] Report location information for MCDwarfCallFrameFragment diagnostics
Added:
Modified:
llvm/include/llvm/MC/MCFragment.h
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/test/MC/MachO/cfi-advance-loc-err.s
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h
index f040cea801f84..0c7e97368e213 100644
--- a/llvm/include/llvm/MC/MCFragment.h
+++ b/llvm/include/llvm/MC/MCFragment.h
@@ -488,6 +488,7 @@ class MCDwarfCallFrameFragment : public MCEncodedFragmentWithFixups<8, 1> {
AddrDelta(&AddrDelta) {}
const MCExpr &getAddrDelta() const { return *AddrDelta; }
+ void setAddrDelta(const MCExpr *E) { AddrDelta = E; }
static bool classof(const MCFragment *F) {
return F->getKind() == MCFragment::FT_DwarfFrame;
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index cde1d75cd30c7..24172a4575299 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -1115,6 +1115,7 @@ bool MCAssembler::relaxDwarfCallFrameFragment(MCAsmLayout &Layout,
if (!Abs) {
getContext().reportError(DF.getAddrDelta().getLoc(),
"invalid CFI advance_loc expression");
+ DF.setAddrDelta(MCConstantExpr::create(0, Context));
return false;
}
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 4d21098553fe5..177f957a3f377 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1476,7 +1476,7 @@ void FrameEmitterImpl::emitCFIInstructions(ArrayRef<MCCFIInstruction> Instrs,
if (BaseLabel && Label) {
MCSymbol *ThisSym = Label;
if (ThisSym != BaseLabel) {
- Streamer.emitDwarfAdvanceFrameAddr(BaseLabel, ThisSym, {});
+ Streamer.emitDwarfAdvanceFrameAddr(BaseLabel, ThisSym, Instr.getLoc());
BaseLabel = ThisSym;
}
}
diff --git a/llvm/test/MC/MachO/cfi-advance-loc-err.s b/llvm/test/MC/MachO/cfi-advance-loc-err.s
index a049c197ab320..3143dd84efc63 100644
--- a/llvm/test/MC/MachO/cfi-advance-loc-err.s
+++ b/llvm/test/MC/MachO/cfi-advance-loc-err.s
@@ -1,7 +1,5 @@
# RUN: not llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
-# CHECK-COUNT-4: <unknown>:0: error: invalid CFI advance_loc expression
-
.section __TEXT,__text
.globl _foo
_foo:
@@ -13,9 +11,11 @@ _foo:
tmp0: # non-private label cannot appear here
addq $8, %rsp
+# CHECK: :[[#@LINE+1]]:3: error: invalid CFI advance_loc expression
.cfi_adjust_cfa_offset -8
.tmp1: # non-private label cannot appear here
addq $8, %rsp
+# CHECK: :[[#@LINE+1]]:3: error: invalid CFI advance_loc expression
.cfi_adjust_cfa_offset -8
retq
.cfi_endproc
More information about the llvm-commits
mailing list