summaryrefslogtreecommitdiffstats
path: root/clang/tools/driver/cc1as_main.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-03-31 23:47:13 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-03-31 23:47:13 +0000
commitb31e1d16df8e4aba562841c1a3aaf20d3c705c23 (patch)
tree5367703e6865af2046a5bc144c9813a0523f288d /clang/tools/driver/cc1as_main.cpp
parentd3bafe3e41aab45def514440d72fe43b2072c56d (diff)
downloadbcm5719-llvm-b31e1d16df8e4aba562841c1a3aaf20d3c705c23.tar.gz
bcm5719-llvm-b31e1d16df8e4aba562841c1a3aaf20d3c705c23.zip
Comment necessity of early initialization
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. llvm-svn: 205267
Diffstat (limited to 'clang/tools/driver/cc1as_main.cpp')
-rw-r--r--clang/tools/driver/cc1as_main.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 0d06371dc16..8521c2a1201 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -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,
OpenPOWER on IntegriCloud