Call generateCompactUnwindEncodings() right before we need to output the frame inform...
authorBill Wendling <isanbard@gmail.com>
Mon, 9 Sep 2013 19:48:37 +0000 (19:48 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 9 Sep 2013 19:48:37 +0000 (19:48 +0000)
There are more than one paths to where the frame information is emitted. Place
the call to generateCompactUnwindEncodings() into the method which outputs the
frame information, thus ensuring that the encoding is there for every path. This
involved threading the MCAsmBackend object through to this method.

<rdar://problem/13623355>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190335 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCDwarf.h
include/llvm/MC/MCStreamer.h
lib/CodeGen/LLVMTargetMachine.cpp
lib/MC/MCAsmStreamer.cpp
lib/MC/MCDwarf.cpp
lib/MC/MCELFStreamer.cpp
lib/MC/MCMachOStreamer.cpp
lib/MC/MCStreamer.cpp

index c671dd9fbbce4bfb782cdfa858c2f75cd5f308f2..7a06cc076226d288d0e3746c1097e49ac49016fc 100644 (file)
@@ -23,6 +23,7 @@
 #include <vector>
 
 namespace llvm {
+class MCAsmBackend;
 class MCContext;
 class MCSection;
 class MCStreamer;
@@ -449,7 +450,8 @@ public:
   //
   // This emits the frame info section.
   //
-  static void Emit(MCStreamer &streamer, bool usingCFI, bool isEH);
+  static void Emit(MCStreamer &streamer, MCAsmBackend *MAB,
+                   bool usingCFI, bool isEH);
   static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta);
   static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta,
                                raw_ostream &OS);
index c849e597b6b6c3bfb58d0431751110923887f15f..cd297a4d9dadb76e985d3ab1c35668f970cb654d 100644 (file)
@@ -104,7 +104,7 @@ protected:
   virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame);
   void RecordProcEnd(MCDwarfFrameInfo &Frame);
   virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame);
-  void EmitFrames(bool usingCFI);
+  void EmitFrames(MCAsmBackend *MAB, bool usingCFI);
 
   MCWin64EHUnwindInfo *getCurrentW64UnwindInfo() {
     return CurrentW64UnwindInfo;
@@ -134,7 +134,7 @@ public:
     return *W64UnwindInfos[i];
   }
 
-  void generateCompactUnwindEncodings(MCAsmBackend &MAB);
+  void generateCompactUnwindEncodings(MCAsmBackend *MAB);
 
   /// @name Assembly File Formatting.
   /// @{
index 6fd68ee7750899b3ffa0012d319335e70045d0b3..5699511a4deda545ec3586aa5b589f530dba574d 100644 (file)
@@ -175,12 +175,11 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
 
     // Create a code emitter if asked to show the encoding.
     MCCodeEmitter *MCE = 0;
-    MCAsmBackend *MAB = 0;
-    if (ShowMCEncoding) {
+    if (ShowMCEncoding)
       MCE = getTarget().createMCCodeEmitter(MII, MRI, STI, *Context);
-      MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(), TargetCPU);
-    }
 
+    MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(),
+                                                       TargetCPU);
     MCStreamer *S = getTarget().createAsmStreamer(*Context, Out,
                                                   getVerboseAsm(),
                                                   hasMCUseLoc(),
index 60d72abbcb87868a681e9d059997a41ab5b0c82e..c612a23f953de00ebcffb0f0cd2d7bdc4c41527f 100644 (file)
@@ -1421,8 +1421,9 @@ void MCAsmStreamer::FinishImpl() {
     MCGenDwarfInfo::Emit(this, LineSectionSymbol);
 
   if (!UseCFI)
-    EmitFrames(false);
+    EmitFrames(AsmBackend.get(), false);
 }
+
 MCStreamer *llvm::createAsmStreamer(MCContext &Context,
                                     formatted_raw_ostream &OS,
                                     bool isVerboseAsm, bool useLoc,
index a5528a2d42f8bca63e204aeb4027580de3454c09..f47553204b2a1df03704ace194e97ffefa070e6b 100644 (file)
@@ -1415,9 +1415,10 @@ namespace llvm {
   };
 }
 
-void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
-                               bool UsingCFI,
-                               bool IsEH) {
+void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer, MCAsmBackend *MAB,
+                               bool UsingCFI, bool IsEH) {
+  Streamer.generateCompactUnwindEncodings(MAB);
+
   MCContext &Context = Streamer.getContext();
   const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();
   FrameEmitterImpl Emitter(UsingCFI, IsEH);
index 4661d503c371f685e4d7fe751683cb015372fc72..a04352a8b2893266d79ccddcd2c29206e99769a9 100644 (file)
@@ -528,7 +528,7 @@ void MCELFStreamer::EmitBundleUnlock() {
 }
 
 void MCELFStreamer::FinishImpl() {
-  EmitFrames(true);
+  EmitFrames(NULL, true);
 
   for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(),
                                                 e = LocalCommons.end();
index f914f62c2f78439521618506e13b513f86b071c6..e628461f1d67cffe85fbfd3f359ca02c0419707c 100644 (file)
@@ -396,8 +396,7 @@ void MCMachOStreamer::EmitInstToData(const MCInst &Inst) {
 }
 
 void MCMachOStreamer::FinishImpl() {
-  generateCompactUnwindEncodings(getAssembler().getBackend());
-  EmitFrames(true);
+  EmitFrames(&getAssembler().getBackend(), true);
 
   // We have to set the fragment atom associations so we can relax properly for
   // Mach-O.
index 806bec989688fa468e35f0897d6ad284d0fcc464..c16670ad7ca4f2e7ec35ad033bedb9acf9f222e6 100644 (file)
@@ -73,12 +73,12 @@ raw_ostream &MCStreamer::GetCommentOS() {
   return nulls();
 }
 
-void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend &MAB) {
+void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) {
+  if (!MAB) return;
   for (std::vector<MCDwarfFrameInfo>::iterator I = FrameInfos.begin(),
          E = FrameInfos.end(); I != E; ++I)
-    if (!I->CompactUnwindEncoding)
-      I->CompactUnwindEncoding =
-        MAB.generateCompactUnwindEncoding(I->Instructions);
+    I->CompactUnwindEncoding =
+      MAB->generateCompactUnwindEncoding(I->Instructions);
 }
 
 void MCStreamer::EmitDwarfSetLineAddr(int64_t LineDelta,
@@ -604,15 +604,15 @@ void MCStreamer::EmitRawText(const Twine &T) {
   EmitRawText(Str.str());
 }
 
-void MCStreamer::EmitFrames(bool usingCFI) {
+void MCStreamer::EmitFrames(MCAsmBackend *MAB, bool usingCFI) {
   if (!getNumFrameInfos())
     return;
 
   if (EmitEHFrame)
-    MCDwarfFrameEmitter::Emit(*this, usingCFI, true);
+    MCDwarfFrameEmitter::Emit(*this, MAB, usingCFI, true);
 
   if (EmitDebugFrame)
-    MCDwarfFrameEmitter::Emit(*this, usingCFI, false);
+    MCDwarfFrameEmitter::Emit(*this, MAB, usingCFI, false);
 }
 
 void MCStreamer::EmitW64Tables() {