summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCDwarf.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-07-22 21:18:59 +0000
committerBill Wendling <isanbard@gmail.com>2011-07-22 21:18:59 +0000
commit4d9aa512f8c6007a65e66933aeb10471d8e3826e (patch)
tree74c05880e6f55552859bc7e14ff6e7e5cf03c194 /llvm/lib/MC/MCDwarf.cpp
parent53b74024865db6ff9c964db86a155b33f2364e6b (diff)
downloadbcm5719-llvm-4d9aa512f8c6007a65e66933aeb10471d8e3826e.tar.gz
bcm5719-llvm-4d9aa512f8c6007a65e66933aeb10471d8e3826e.zip
Emit the __compact_unwind section first. If there are any frames which weren't
emitted, emit them next as CIE/FDEs. llvm-svn: 135807
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r--llvm/lib/MC/MCDwarf.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index a200128ab69..06ce502d572 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -504,10 +504,11 @@ namespace {
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 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
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;
OpenPOWER on IntegriCloud