[llvm-commits] [llvm] r135807 - /llvm/trunk/lib/MC/MCDwarf.cpp
Bill Wendling
isanbard at gmail.com
Fri Jul 22 14:18:59 PDT 2011
Author: void
Date: Fri Jul 22 16:18:59 2011
New Revision: 135807
URL: http://llvm.org/viewvc/llvm-project?rev=135807&view=rev
Log:
Emit the __compact_unwind section first. If there are any frames which weren't
emitted, emit them next as CIE/FDEs.
Modified:
llvm/trunk/lib/MC/MCDwarf.cpp
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=135807&r1=135806&r2=135807&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Fri Jul 22 16:18:59 2011
@@ -504,10 +504,11 @@
bool IsEH;
const MCSymbol *SectionStart;
public:
- FrameEmitterImpl(bool usingCFI, bool isEH, const MCSymbol *sectionStart) :
- CFAOffset(0), CIENum(0), UsingCFI(usingCFI), IsEH(isEH),
- SectionStart(sectionStart) {
- }
+ FrameEmitterImpl(bool usingCFI, bool isEH)
+ : CFAOffset(0), CIENum(0), UsingCFI(usingCFI), IsEH(isEH),
+ SectionStart(0) {}
+
+ void setSectionStart(const MCSymbol *Label) { SectionStart = Label; }
/// EmitCompactUnwind - Emit the unwind information in a compact way. If
/// we're successful, return 'true'. Otherwise, return 'false' and it will
@@ -1011,26 +1012,38 @@
MCContext &Context = Streamer.getContext();
MCObjectFileInfo *MOFI =
const_cast<MCObjectFileInfo*>(Context.getObjectFileInfo());
+ FrameEmitterImpl Emitter(UsingCFI, IsEH);
+ SmallVector<MCDwarfFrameInfo, 8> RequiresFDE;
+ ArrayRef<MCDwarfFrameInfo> FrameArray;
+
+ if (IsEH && MOFI->getCompactUnwindSection()) {
+ for (unsigned i = 0, n = Streamer.getNumFrameInfos(); i < n; ++i) {
+ const MCDwarfFrameInfo &Frame = Streamer.getFrameInfo(i);
+ if (!Frame.CompactUnwindEncoding ||
+ !Emitter.EmitCompactUnwind(Streamer, Frame))
+ RequiresFDE.push_back(Streamer.getFrameInfo(i));
+ }
+
+ // Early exit if we don't need to emit FDEs.
+ if (RequiresFDE.empty()) return;
+ FrameArray = RequiresFDE;
+ } else {
+ FrameArray = Streamer.getFrameInfos();
+ }
+
const MCSection &Section = IsEH ? *MOFI->getEHFrameSection() :
*MOFI->getDwarfFrameSection();
Streamer.SwitchSection(&Section);
MCSymbol *SectionStart = Context.CreateTempSymbol();
Streamer.EmitLabel(SectionStart);
+ Emitter.setSectionStart(SectionStart);
MCSymbol *FDEEnd = NULL;
DenseMap<CIEKey, const MCSymbol*> CIEStarts;
- FrameEmitterImpl Emitter(UsingCFI, IsEH, SectionStart);
const MCSymbol *DummyDebugKey = NULL;
- for (unsigned i = 0, n = Streamer.getNumFrameInfos(); i < n; ++i) {
- const MCDwarfFrameInfo &Frame = Streamer.getFrameInfo(i);
- if (IsEH && MOFI->getCompactUnwindSection() &&
- Frame.CompactUnwindEncoding &&
- Emitter.EmitCompactUnwind(Streamer, Frame)) {
- FDEEnd = NULL;
- continue;
- }
-
+ for (unsigned i = 0, n = FrameArray.size(); i < n; ++i) {
+ const MCDwarfFrameInfo &Frame = FrameArray[i];
CIEKey Key(Frame.Personality, Frame.PersonalityEncoding,
Frame.LsdaEncoding);
const MCSymbol *&CIEStart = IsEH ? CIEStarts[Key] : DummyDebugKey;
More information about the llvm-commits
mailing list