diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index 68cf5dd34bf..6cd9a9a21e2 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 Instructions; unsigned PersonalityEncoding; unsigned LsdaEncoding; diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 1c6039bf6d4..bf224979def 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 SymbolOrdering; diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 8f348528cbb..bddbf578d80 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 7dccf0d751d..1b3b2decf35 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()); } @@ -51,7 +51,6 @@ void MCStreamer::reset() { delete W64UnwindInfos[i]; W64UnwindInfos.clear(); CurrentW64UnwindInfo = nullptr; - LastSymbol = nullptr; SectionStack.clear(); SectionStack.push_back(std::pair()); } @@ -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 57ded13d0f7..00000000000 --- 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. -# - -# 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 00000000000..a1e524662a9 --- /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: ]