summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-06-23 15:34:32 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-06-23 15:34:32 +0000
commit88a564f55ee92e2ffe916d8d69271308d05479d1 (patch)
treeaf1ddcce1f9150f96762c61212f5ec5d41279e1e
parent1e1bf1bf76f3e851092fec95ba3f748b96174d8d (diff)
downloadllvm-88a564f55ee92e2ffe916d8d69271308d05479d1.tar.gz
llvm-88a564f55ee92e2ffe916d8d69271308d05479d1.tar.bz2
llvm-88a564f55ee92e2ffe916d8d69271308d05479d1.tar.xz
Allow using .cfi_startproc without a leading symbol.
This is possible now that we don't produce .eh symbols. This fixes pr19430. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211502 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/MC/MCDwarf.h6
-rw-r--r--include/llvm/MC/MCStreamer.h2
-rw-r--r--lib/MC/MCDwarf.cpp2
-rw-r--r--lib/MC/MCStreamer.cpp10
-rw-r--r--test/MC/AsmParser/cfi-invalid-startproc.s16
-rw-r--r--test/MC/ELF/pr19430.s14
6 files changed, 18 insertions, 32 deletions
diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h
index 68cf5dd34b..6cd9a9a21e 100644
--- a/include/llvm/MC/MCDwarf.h
+++ b/include/llvm/MC/MCDwarf.h
@@ -466,14 +466,12 @@ public:
struct MCDwarfFrameInfo {
MCDwarfFrameInfo()
: Begin(nullptr), End(nullptr), Personality(nullptr), Lsda(nullptr),
- Function(nullptr), Instructions(), PersonalityEncoding(),
- LsdaEncoding(0), CompactUnwindEncoding(0), IsSignalFrame(false),
- IsSimple(false) {}
+ Instructions(), PersonalityEncoding(), LsdaEncoding(0),
+ CompactUnwindEncoding(0), IsSignalFrame(false), IsSimple(false) {}
MCSymbol *Begin;
MCSymbol *End;
const MCSymbol *Personality;
const MCSymbol *Lsda;
- const MCSymbol *Function;
std::vector<MCCFIInstruction> Instructions;
unsigned PersonalityEncoding;
unsigned LsdaEncoding;
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
index 1c6039bf6d..bf224979de 100644
--- a/include/llvm/MC/MCStreamer.h
+++ b/include/llvm/MC/MCStreamer.h
@@ -164,8 +164,6 @@ class MCStreamer {
void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame);
void EnsureValidW64UnwindInfo();
- MCSymbol *LastSymbol;
-
// SymbolOrdering - Tracks an index to represent the order
// a symbol was emitted in. Zero means we did not emit that symbol.
DenseMap<const MCSymbol *, unsigned> SymbolOrdering;
diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp
index 8f348528cb..bddbf578d8 100644
--- a/lib/MC/MCDwarf.cpp
+++ b/lib/MC/MCDwarf.cpp
@@ -1297,7 +1297,7 @@ void FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer,
unsigned FDEEncoding = MOFI->getFDEEncoding();
unsigned Size = getSizeForEncoding(Streamer, FDEEncoding);
if (VerboseAsm) Streamer.AddComment("Range Start");
- Streamer.EmitSymbolValue(Frame.Function, Size);
+ Streamer.EmitSymbolValue(Frame.Begin, Size);
// Range Length
const MCExpr *Range = MakeStartMinusEndExpr(Streamer, *Frame.Begin,
diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp
index 7dccf0d751..1b3b2decf3 100644
--- a/lib/MC/MCStreamer.cpp
+++ b/lib/MC/MCStreamer.cpp
@@ -37,7 +37,7 @@ void MCTargetStreamer::finish() {}
void MCTargetStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {}
MCStreamer::MCStreamer(MCContext &Ctx)
- : Context(Ctx), CurrentW64UnwindInfo(nullptr), LastSymbol(nullptr) {
+ : Context(Ctx), CurrentW64UnwindInfo(nullptr) {
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
}
@@ -51,7 +51,6 @@ void MCStreamer::reset() {
delete W64UnwindInfos[i];
W64UnwindInfos.clear();
CurrentW64UnwindInfo = nullptr;
- LastSymbol = nullptr;
SectionStack.clear();
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
}
@@ -234,7 +233,6 @@ void MCStreamer::EmitLabel(MCSymbol *Symbol) {
assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
assert(getCurrentSection().first && "Cannot emit before setting section!");
AssignSection(Symbol, getCurrentSection().first);
- LastSymbol = Symbol;
MCTargetStreamer *TS = getTargetStreamer();
if (TS)
@@ -245,7 +243,6 @@ void MCStreamer::EmitDebugLabel(MCSymbol *Symbol) {
assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
assert(getCurrentSection().first && "Cannot emit before setting section!");
AssignSection(Symbol, getCurrentSection().first);
- LastSymbol = Symbol;
}
void MCStreamer::EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding) {
@@ -274,11 +271,6 @@ void MCStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
}
void MCStreamer::RecordProcStart(MCDwarfFrameInfo &Frame) {
- // Report an error if we haven't seen a symbol yet where we'd bind
- // .cfi_startproc.
- if (!LastSymbol)
- report_fatal_error("No symbol to start a frame");
- Frame.Function = LastSymbol;
// We need to create a local symbol to avoid relocations.
Frame.Begin = getContext().CreateTempSymbol();
EmitLabel(Frame.Begin);
diff --git a/test/MC/AsmParser/cfi-invalid-startproc.s b/test/MC/AsmParser/cfi-invalid-startproc.s
deleted file mode 100644
index 57ded13d0f..0000000000
--- a/test/MC/AsmParser/cfi-invalid-startproc.s
+++ /dev/null
@@ -1,16 +0,0 @@
-# RUN: not llvm-mc -triple=x86_64-apple-macosx10.8 -filetype=obj -o %t %s 2>&1 | FileCheck %s
-# Check that the cfi_startproc is declared after the beginning of
-# a procedure, otherwise it will reference an invalid symbol for
-# emitting the relocation.
-# <rdar://problem/15939159>
-
-# CHECK: No symbol to start a frame
-.text
-.cfi_startproc
-.globl _someFunction
-_someFunction:
-.cfi_def_cfa_offset 16
-.cfi_offset %rbp, -16
-.cfi_def_cfa_register rbp
- ret
-.cfi_endproc
diff --git a/test/MC/ELF/pr19430.s b/test/MC/ELF/pr19430.s
new file mode 100644
index 0000000000..a1e524662a
--- /dev/null
+++ b/test/MC/ELF/pr19430.s
@@ -0,0 +1,14 @@
+// RUN: llvm-mc -triple x86_64-pc-linux-gnu %s -filetype=obj -o - | llvm-readobj -r | FileCheck %s
+
+// Test that we can use .cfi_startproc without a global symbol.
+
+.text
+.space 1000
+.cfi_startproc
+ .cfi_endproc
+
+// CHECK: Relocations [
+// CHECK-NEXT: Section (5) .rela.eh_frame {
+// CHECK-NEXT: 0x20 R_X86_64_PC32 .text 0x3E8
+// CHECK-NEXT: }
+// CHECK-NEXT: ]