]> granicus.if.org Git - clang/commitdiff
Comment necessity of early initialization
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 31 Mar 2014 23:47:13 +0000 (23:47 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 31 Mar 2014 23:47:13 +0000 (23:47 +0000)
Code review feedback from Eric Christopher on r204261.

I didn't want to go into too much detail (the revision history should
provide the full stuff) - but I can add more if that's preferred.

Also moved this up to right by the construction of the MCAsmInfo so
there's less chance that other things might sneak in in between.

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

tools/driver/cc1as_main.cpp

index 0d06371dc16d2a55f42eeba5187a013376d3d8ff..8521c2a1201b635076ef47630a089e4798b8da64 100644 (file)
@@ -296,6 +296,11 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
   std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, Opts.Triple));
   assert(MAI && "Unable to create target asm info!");
 
+  // Ensure MCAsmInfo initialization occurs before any use, otherwise sections
+  // may be created with a combination of default and explicit settings.
+  if (Opts.CompressDebugSections)
+    MAI->setCompressDebugSections(true);
+
   bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;
   formatted_raw_ostream *Out = GetOutputStream(Opts, Diags, IsBinary);
   if (!Out)
@@ -305,9 +310,6 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
   std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
 
-  if (Opts.CompressDebugSections)
-    MAI->setCompressDebugSections(true);
-
   MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
   // FIXME: Assembler behavior can change with -static.
   MOFI->InitMCObjectFileInfo(Opts.Triple,