[llvm-commits] [llvm] r147717 - in /llvm/trunk: include/llvm/MC/MCExpr.h include/llvm/MC/MCObjectStreamer.h include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCELFStreamer.cpp lib/MC/MCELFStreamer.h lib/MC/MCLoggingStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCNullStreamer.cpp lib/MC/MCObjectStreamer.cpp lib/MC/MCPureStreamer.cpp lib/MC/MCStreamer.cpp lib/MC/WinCOFFStreamer.cpp lib/Target/PTX/PTXMCAsmStreamer.cpp test/MC/AsmParser/cfi-unfinished-frame.s tools/lto/LTOModule.cpp
Rafael Espindola
rafael.espindola at gmail.com
Fri Jan 6 19:13:19 PST 2012
Author: rafael
Date: Fri Jan 6 21:13:18 2012
New Revision: 147717
URL: http://llvm.org/viewvc/llvm-project?rev=147717&view=rev
Log:
Split Finish into Finish and FinishImpl to have a common place to do end of
file error checking. Use that to error on an unfinished cfi_startproc.
The error is not nice, but is already better than a segmentation fault.
Added:
llvm/trunk/test/MC/AsmParser/cfi-unfinished-frame.s
Modified:
llvm/trunk/include/llvm/MC/MCExpr.h
llvm/trunk/include/llvm/MC/MCObjectStreamer.h
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCELFStreamer.h
llvm/trunk/lib/MC/MCLoggingStreamer.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCNullStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/MCPureStreamer.cpp
llvm/trunk/lib/MC/MCStreamer.cpp
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp
llvm/trunk/tools/lto/LTOModule.cpp
Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Fri Jan 6 21:13:18 2012
@@ -204,7 +204,9 @@
const VariantKind Kind;
explicit MCSymbolRefExpr(const MCSymbol *_Symbol, VariantKind _Kind)
- : MCExpr(MCExpr::SymbolRef), Symbol(_Symbol), Kind(_Kind) {}
+ : MCExpr(MCExpr::SymbolRef), Symbol(_Symbol), Kind(_Kind) {
+ assert(Symbol);
+ }
public:
/// @name Construction
Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Fri Jan 6 21:13:18 2012
@@ -78,7 +78,7 @@
virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
const MCSymbol *Label);
virtual void EmitGPRel32Value(const MCExpr *Value);
- virtual void Finish();
+ virtual void FinishImpl();
/// @}
};
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Fri Jan 6 21:13:18 2012
@@ -590,8 +590,10 @@
virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList,
bool isVector);
+ /// FinishImpl - Streamer specific finalization.
+ virtual void FinishImpl() = 0;
/// Finish - Finish emission of machine code.
- virtual void Finish() = 0;
+ void Finish();
};
/// createNullStreamer - Create a dummy machine code streamer, which does
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -255,7 +255,7 @@
/// indicated by the hasRawTextSupport() predicate.
virtual void EmitRawText(StringRef String);
- virtual void Finish();
+ virtual void FinishImpl();
/// @}
};
@@ -1285,7 +1285,7 @@
EmitEOL();
}
-void MCAsmStreamer::Finish() {
+void MCAsmStreamer::FinishImpl() {
// Dump out the dwarf file & directory tables and line tables.
if (getContext().hasDwarfFiles() && !UseLoc)
MCDwarfFileTable::Emit(this);
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -356,7 +356,7 @@
DF->getContents().append(Code.begin(), Code.end());
}
-void MCELFStreamer::Finish() {
+void MCELFStreamer::FinishImpl() {
EmitFrames(true);
for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(),
@@ -379,7 +379,7 @@
SectData.setAlignment(ByteAlignment);
}
- this->MCObjectStreamer::Finish();
+ this->MCObjectStreamer::FinishImpl();
}
MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
Modified: llvm/trunk/lib/MC/MCELFStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.h?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.h (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.h Fri Jan 6 21:13:18 2012
@@ -94,7 +94,7 @@
virtual void EmitFileDirective(StringRef Filename);
- virtual void Finish();
+ virtual void FinishImpl();
private:
virtual void EmitInstToFragment(const MCInst &Inst);
Modified: llvm/trunk/lib/MC/MCLoggingStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCLoggingStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCLoggingStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCLoggingStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -243,9 +243,9 @@
return Child->EmitRawText(String);
}
- virtual void Finish() {
- LogCall("Finish");
- return Child->Finish();
+ virtual void FinishImpl() {
+ LogCall("FinishImpl");
+ return Child->FinishImpl();
}
};
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -89,7 +89,7 @@
//report_fatal_error("unsupported directive: '.file'");
}
- virtual void Finish();
+ virtual void FinishImpl();
/// @}
};
@@ -375,7 +375,7 @@
DF->getContents().append(Code.begin(), Code.end());
}
-void MCMachOStreamer::Finish() {
+void MCMachOStreamer::FinishImpl() {
EmitFrames(true);
// We have to set the fragment atom associations so we can relax properly for
@@ -407,7 +407,7 @@
}
}
- this->MCObjectStreamer::Finish();
+ this->MCObjectStreamer::FinishImpl();
}
MCStreamer *llvm::createMachOStreamer(MCContext &Context, MCAsmBackend &MAB,
Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCNullStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCNullStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -94,7 +94,7 @@
StringRef FileName) {}
virtual void EmitInstruction(const MCInst &Inst) {}
- virtual void Finish() {}
+ virtual void FinishImpl() {}
/// @}
};
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -255,7 +255,7 @@
DF->getContents().resize(DF->getContents().size() + 4, 0);
}
-void MCObjectStreamer::Finish() {
+void MCObjectStreamer::FinishImpl() {
// Dump out the dwarf file & directory tables and line tables.
if (getContext().hasDwarfFiles())
MCDwarfFileTable::Emit(this);
Modified: llvm/trunk/lib/MC/MCPureStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCPureStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCPureStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCPureStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -48,7 +48,7 @@
unsigned MaxBytesToEmit = 0);
virtual void EmitValueToOffset(const MCExpr *Offset,
unsigned char Value = 0);
- virtual void Finish();
+ virtual void FinishImpl();
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) {
@@ -224,10 +224,10 @@
DF->getContents().append(Code.begin(), Code.end());
}
-void MCPureStreamer::Finish() {
+void MCPureStreamer::FinishImpl() {
// FIXME: Handle DWARF tables?
- this->MCObjectStreamer::Finish();
+ this->MCObjectStreamer::FinishImpl();
}
MCStreamer *llvm::createPureStreamer(MCContext &Context, MCAsmBackend &MAB,
Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -652,3 +652,10 @@
MCWin64EHUnwindEmitter::Emit(*this);
}
+
+void MCStreamer::Finish() {
+ if (!FrameInfos.empty() && !FrameInfos.back().End)
+ report_fatal_error("Unfinished frame!");
+
+ FinishImpl();
+}
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -79,7 +79,7 @@
virtual void EmitFileDirective(StringRef Filename);
virtual void EmitInstruction(const MCInst &Instruction);
virtual void EmitWin64EHHandlerData();
- virtual void Finish();
+ virtual void FinishImpl();
private:
virtual void EmitInstToFragment(const MCInst &Inst) {
@@ -401,9 +401,9 @@
MCWin64EHUnwindEmitter::EmitUnwindInfo(*this, getCurrentW64UnwindInfo());
}
-void WinCOFFStreamer::Finish() {
+void WinCOFFStreamer::FinishImpl() {
EmitW64Tables();
- MCObjectStreamer::Finish();
+ MCObjectStreamer::FinishImpl();
}
namespace llvm
Modified: llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp Fri Jan 6 21:13:18 2012
@@ -176,7 +176,7 @@
/// indicated by the hasRawTextSupport() predicate.
virtual void EmitRawText(StringRef String);
- virtual void Finish();
+ virtual void FinishImpl();
/// @}
@@ -540,7 +540,7 @@
EmitEOL();
}
-void PTXMCAsmStreamer::Finish() {}
+void PTXMCAsmStreamer::FinishImpl() {}
namespace llvm {
MCStreamer *createPTXAsmStreamer(MCContext &Context,
Added: llvm/trunk/test/MC/AsmParser/cfi-unfinished-frame.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/cfi-unfinished-frame.s?rev=147717&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/cfi-unfinished-frame.s (added)
+++ llvm/trunk/test/MC/AsmParser/cfi-unfinished-frame.s Fri Jan 6 21:13:18 2012
@@ -0,0 +1,5 @@
+// RUN: not llvm-mc -filetype=asm -triple x86_64-pc-linux-gnu %s -o %t 2>%t.out
+// RUN: FileCheck -input-file=%t.out %s
+
+.cfi_startproc
+// CHECK: Unfinished frame
Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=147717&r1=147716&r2=147717&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Fri Jan 6 21:13:18 2012
@@ -603,7 +603,7 @@
if (Inst.getOperand(i).isExpr())
AddValueSymbols(Inst.getOperand(i).getExpr());
}
- virtual void Finish() {}
+ virtual void FinishImpl() {}
};
}
More information about the llvm-commits
mailing list