Index: src/IceTranslator.cpp |
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp |
index c0331a8718df28fe05546d2812995340e76db6ca..351b13ca9e5fc02eb37a121543e687aeb75da81f 100644 |
--- a/src/IceTranslator.cpp |
+++ b/src/IceTranslator.cpp |
@@ -103,21 +103,35 @@ void Translator::emitConstants() { |
} |
void Translator::lowerGlobals( |
- const VariableDeclarationListType &VariableDeclarations) { |
+ const VariableDeclarationList &VariableDeclarations) { |
+ TimerMarker T(TimerStack::TT_emitGlobalInitializers, Ctx); |
std::unique_ptr<TargetGlobalInitLowering> GlobalLowering( |
TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); |
bool DisableTranslation = Ctx->getFlags().DisableTranslation; |
const bool DumpGlobalVariables = |
ALLOW_DUMP && Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty(); |
- OstreamLocker L(Ctx); |
- Ostream &Stream = Ctx->getStrDump(); |
- const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly; |
- for (const Ice::VariableDeclaration *Global : VariableDeclarations) { |
- if (DumpGlobalVariables) |
- Global->dump(getContext(), Stream); |
- if (!DisableTranslation && |
- matchSymbolName(Global->getName(), TranslateOnly)) |
- GlobalLowering->lower(*Global); |
+ if (Ctx->getFlags().UseELFWriter) { |
+ // Dump all globals if requested, but don't interleave w/ emission. |
+ if (DumpGlobalVariables) { |
+ OstreamLocker L(Ctx); |
+ Ostream &Stream = Ctx->getStrDump(); |
+ for (const Ice::VariableDeclaration *Global : VariableDeclarations) { |
+ Global->dump(getContext(), Stream); |
+ } |
+ } |
+ GlobalLowering->lowerGlobalsELF(VariableDeclarations); |
+ } else { |
+ const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly; |
+ OstreamLocker L(Ctx); |
+ Ostream &Stream = Ctx->getStrDump(); |
+ for (const Ice::VariableDeclaration *Global : VariableDeclarations) { |
+ // Interleave dump output w/ emit output. |
+ if (DumpGlobalVariables) |
+ Global->dump(getContext(), Stream); |
+ if (!DisableTranslation && |
+ matchSymbolName(Global->getName(), TranslateOnly)) |
+ GlobalLowering->lower(*Global); |
+ } |
} |
GlobalLowering.reset(); |
} |