Chromium Code Reviews| 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]); |
| } |