Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: src/PNaClTranslator.cpp

Issue 587893003: Test generation of global initializers in Subzero bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTranslator.cpp ('k') | tests_lit/reader_tests/globalinit.pnacl.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index e87e0aa2b2cfb6254a016e05fd1c988d463e49c5..c24f2af899662658b922a27bdd2d3b2a731b1544 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -351,7 +351,9 @@ protected:
Context(EnclosingParser->Context) {}
// Gets the translator associated with the bitcode parser.
- Ice::Translator &getTranslator() { return Context->getTranslator(); }
+ Ice::Translator &getTranslator() const { return Context->getTranslator(); }
+
+ const Ice::ClFlags &getFlags() const { return getTranslator().getFlags(); }
// Generates an error Message with the bit address prefixed to it.
virtual bool Error(const std::string &Message) LLVM_OVERRIDE {
@@ -1376,7 +1378,7 @@ private:
};
FunctionParser::~FunctionParser() {
- if (getTranslator().getFlags().SubzeroTimingEnabled) {
+ if (getFlags().SubzeroTimingEnabled) {
errs() << "[Subzero timing] Convert function " << Func->getFunctionName()
<< ": " << TConvert.getElapsedSec() << " sec\n";
}
@@ -2216,16 +2218,36 @@ bool FunctionParser::ParseBlock(unsigned BlockID) {
class ModuleParser : public BlockParserBaseClass {
public:
ModuleParser(unsigned BlockID, TopLevelParser *Context)
- : BlockParserBaseClass(BlockID, Context), FoundFirstFunctionBlock(false) {
- }
+ : BlockParserBaseClass(BlockID, Context),
+ GlobalAddressNamesAndInitializersInstalled(false) {}
virtual ~ModuleParser() LLVM_OVERRIDE {}
private:
- // True if we have parsed a function block.
- bool FoundFirstFunctionBlock;
+ // True if we have already install names for unnamed global addresses,
Jim Stichnoth 2014/09/22 17:01:43 installed
Karl 2014/09/22 17:29:22 Done.
+ // and generated global constant initializers.
+ bool GlobalAddressNamesAndInitializersInstalled;
+
+ // Temporary hack to generate names for unnamed global addresses,
+ // and generate global constant initializers. May be called multiple
+ // times. Only the first call will do the installation.
+ // NOTE: Doesn't handle relocations for global constant initializers.
+ void InstallGlobalAddressNamesAndInitializers() {
+ if (!GlobalAddressNamesAndInitializersInstalled) {
+ getTranslator().nameUnnamedGlobalAddresses(Context->getModule());
+ if (!getFlags().DisableGlobals)
+ getTranslator().convertGlobals(Context->getModule());
+ GlobalAddressNamesAndInitializersInstalled = true;
+ }
+ }
+
virtual bool ParseBlock(unsigned BlockID) LLVM_OVERRIDE;
+ virtual void ExitBlock() LLVM_OVERRIDE {
+ InstallGlobalAddressNamesAndInitializers();
+ getTranslator().emitConstants();
+ }
+
virtual void ProcessRecord() LLVM_OVERRIDE;
};
@@ -2282,10 +2304,7 @@ bool ModuleParser::ParseBlock(unsigned BlockID) LLVM_OVERRIDE {
return Parser.ParseThisBlock();
}
case naclbitc::FUNCTION_BLOCK_ID: {
- if (!FoundFirstFunctionBlock) {
- getTranslator().nameUnnamedGlobalAddresses(Context->getModule());
- FoundFirstFunctionBlock = true;
- }
+ InstallGlobalAddressNamesAndInitializers();
FunctionParser Parser(BlockID, this);
return Parser.ParseThisBlock();
}
« no previous file with comments | « src/IceTranslator.cpp ('k') | tests_lit/reader_tests/globalinit.pnacl.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698