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

Unified Diff: src/PNaClTranslator.cpp

Issue 902713002: Allow stubbing of called constant addresses using command line argument. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix formatting. Created 5 years, 10 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/IceClFlags.h ('k') | src/llvm2ice.cpp » ('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 4d8357879281c78eae49809c717a3ebcdf94450c..f8cecf5e7e2cfe9519e2ded2f4a521eb1a90f376 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -163,7 +163,7 @@ public:
NaClBitstreamCursor &Cursor, Ice::ErrorCode &ErrorStatus)
: NaClBitcodeParser(Cursor), Translator(Translator), Header(Header),
ErrorStatus(ErrorStatus), NumErrors(0), NextDefiningFunctionID(0),
- BlockParser(nullptr) {}
+ BlockParser(nullptr), StubbedConstCallValue(nullptr) {}
~TopLevelParser() override {}
@@ -319,6 +319,23 @@ public:
return C;
}
+ /// Returns a defined function reference to be used in place of
+ /// called constant addresses. Returns the corresponding operand
+ /// to replace the calling address with.
+ Ice::Operand *getStubbedConstCallValue() {
+ if (StubbedConstCallValue)
+ return StubbedConstCallValue;
+ for (unsigned i = 0; i < getNumFunctionIDs(); ++i) {
+ Ice::FunctionDeclaration *Func = getFunctionByID(i);
+ if (!Func->isProto()) {
+ StubbedConstCallValue = getOrCreateGlobalConstantByID(i);
+ return StubbedConstCallValue;
+ }
+ }
+ Error("Unable to find function definition to stub constant calls with");
+ report_fatal_error("Unable to continue");
+ }
+
/// Returns the number of function declarations in the bitcode file.
unsigned getNumFunctionIDs() const { return FunctionDeclarationList.size(); }
@@ -393,6 +410,8 @@ private:
// The block parser currently being applied. Used for error
// reporting.
BlockParserBaseClass *BlockParser;
+ // Value to use to stub constant calls.
+ Ice::Operand *StubbedConstCallValue;
bool ParseBlock(unsigned BlockID) override;
@@ -2441,6 +2460,10 @@ void FunctionParser::ProcessRecord() {
}
}
} else {
+ if (getFlags().StubConstantCalls &&
+ Callee->getKind() == Ice::Operand::kConstInteger32) {
Jim Stichnoth 2015/02/04 22:24:13 Can you use llvm::isa<Ice::ConstantInteger32>(Ca
Karl 2015/02/04 22:46:54 Done.
+ Callee = Context->getStubbedConstCallValue();
+ }
ReturnType = Context->getSimpleTypeByID(Values[2]);
}
« no previous file with comments | « src/IceClFlags.h ('k') | src/llvm2ice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698