summaryrefslogtreecommitdiff
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
commit639e728172dcbdcb6a54fc940100ccaefc7bf6f4 (patch)
treea16e10872bd92f5aecc5c1f11a4a8fcd7cf02cdf
parente3989ea116ea77ecbfc1699dd862692f817ddae9 (diff)
downloadclang-639e728172dcbdcb6a54fc940100ccaefc7bf6f4.tar.gz
clang-639e728172dcbdcb6a54fc940100ccaefc7bf6f4.tar.bz2
clang-639e728172dcbdcb6a54fc940100ccaefc7bf6f4.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205267 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/driver/cc1as_main.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
index 0d06371dc1..8521c2a120 100644
--- a/tools/driver/cc1as_main.cpp
+++ b/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,