Allow ability to name unnamed global addresses in Subzero.
This is a workaround for issue that Subzero currently assumes all
global addresses have a name, but finalized pexe files leave most
global addresses unnamed.
It does this by allowing two optional command-line flag name prefixes
that are used to generate names for unnamed global addresses.
BUG= None
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/567703003
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index bb04d61..fcebeac 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -1887,11 +1887,14 @@
class ModuleParser : public BlockParserBaseClass {
public:
ModuleParser(unsigned BlockID, TopLevelParser *Context)
- : BlockParserBaseClass(BlockID, Context) {}
+ : BlockParserBaseClass(BlockID, Context), FoundFirstFunctionBlock(false) {
+ }
virtual ~ModuleParser() LLVM_OVERRIDE {}
-protected:
+private:
+ // True if we have parsed a function block.
+ bool FoundFirstFunctionBlock;
virtual bool ParseBlock(unsigned BlockID) LLVM_OVERRIDE;
virtual void ProcessRecord() LLVM_OVERRIDE;
@@ -1950,6 +1953,10 @@
return Parser.ParseThisBlock();
}
case naclbitc::FUNCTION_BLOCK_ID: {
+ if (!FoundFirstFunctionBlock) {
+ getTranslator().nameUnnamedGlobalAddresses(Context->getModule());
+ FoundFirstFunctionBlock = true;
+ }
FunctionParser Parser(BlockID, this);
return Parser.ParseThisBlock();
}