From 4c5e43da7792f75567b693105cc53e3f1992ad98 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Wed, 8 Apr 2015 08:55:49 -0700 Subject: Update aosp/master llvm for rebase to r233350 Change-Id: I07d935f8793ee8ec6b7da003f6483046594bca49 --- examples/ExceptionDemo/CMakeLists.txt | 2 +- examples/ExceptionDemo/ExceptionDemo.cpp | 4 ++-- examples/HowToUseJIT/HowToUseJIT.cpp | 1 + examples/Kaleidoscope/Chapter4/toy.cpp | 3 +-- examples/Kaleidoscope/Chapter5/toy.cpp | 4 ++-- examples/Kaleidoscope/Chapter6/toy.cpp | 4 ++-- examples/Kaleidoscope/Chapter7/toy.cpp | 4 ++-- examples/Kaleidoscope/Chapter8/toy.cpp | 4 ++-- examples/Kaleidoscope/Orc/fully_lazy/toy.cpp | 25 ++++++++++++------------- examples/Kaleidoscope/Orc/initial/toy.cpp | 2 +- examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp | 2 +- examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp | 23 ++++++++++------------- examples/ParallelJIT/ParallelJIT.cpp | 1 + 13 files changed, 38 insertions(+), 41 deletions(-) (limited to 'examples') diff --git a/examples/ExceptionDemo/CMakeLists.txt b/examples/ExceptionDemo/CMakeLists.txt index 9cadd94..2a7667d 100644 --- a/examples/ExceptionDemo/CMakeLists.txt +++ b/examples/ExceptionDemo/CMakeLists.txt @@ -15,4 +15,4 @@ add_llvm_example(ExceptionDemo ExceptionDemo.cpp ) -set_target_properties(ExceptionDemo PROPERTIES ENABLE_EXPORTS 1) +export_executable_symbols(ExceptionDemo) diff --git a/examples/ExceptionDemo/ExceptionDemo.cpp b/examples/ExceptionDemo/ExceptionDemo.cpp index 317a326..d68c05f 100644 --- a/examples/ExceptionDemo/ExceptionDemo.cpp +++ b/examples/ExceptionDemo/ExceptionDemo.cpp @@ -48,6 +48,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/STLExtras.h" #include "llvm/IR/Verifier.h" #include "llvm/ExecutionEngine/MCJIT.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" @@ -1971,8 +1972,7 @@ int main(int argc, char *argv[]) { // Set up the optimizer pipeline. // Start with registering info about how the // target lays out data structures. - module->setDataLayout(executionEngine->getDataLayout()); - fpm.add(new llvm::DataLayoutPass()); + module->setDataLayout(*executionEngine->getDataLayout()); // Optimizations turned on #ifdef ADD_OPT_PASSES diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp index 9552240..91ea17d 100644 --- a/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/examples/HowToUseJIT/HowToUseJIT.cpp @@ -34,6 +34,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/IR/Constants.h" diff --git a/examples/Kaleidoscope/Chapter4/toy.cpp b/examples/Kaleidoscope/Chapter4/toy.cpp index 70fe57f..329c3be 100644 --- a/examples/Kaleidoscope/Chapter4/toy.cpp +++ b/examples/Kaleidoscope/Chapter4/toy.cpp @@ -560,8 +560,7 @@ void *MCJITHelper::getPointerToFunction(Function *F) { // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. - OpenModule->setDataLayout(NewEngine->getDataLayout()); - FPM->add(new DataLayoutPass()); + OpenModule->setDataLayout(*NewEngine->getDataLayout()); // Provide basic AliasAnalysis support for GVN. FPM->add(createBasicAliasAnalysisPass()); // Promote allocas to registers. diff --git a/examples/Kaleidoscope/Chapter5/toy.cpp b/examples/Kaleidoscope/Chapter5/toy.cpp index 728a2f5..8ebc2bc 100644 --- a/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/examples/Kaleidoscope/Chapter5/toy.cpp @@ -1,3 +1,4 @@ +#include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/Passes.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/MCJIT.h" @@ -912,8 +913,7 @@ int main() { // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. - TheModule->setDataLayout(TheExecutionEngine->getDataLayout()); - OurFPM.add(new DataLayoutPass()); + TheModule->setDataLayout(*TheExecutionEngine->getDataLayout()); // Provide basic AliasAnalysis support for GVN. OurFPM.add(createBasicAliasAnalysisPass()); // Do simple "peephole" optimizations and bit-twiddling optzns. diff --git a/examples/Kaleidoscope/Chapter6/toy.cpp b/examples/Kaleidoscope/Chapter6/toy.cpp index 8131aa1..eb7e8e1 100644 --- a/examples/Kaleidoscope/Chapter6/toy.cpp +++ b/examples/Kaleidoscope/Chapter6/toy.cpp @@ -1,3 +1,4 @@ +#include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/Passes.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/MCJIT.h" @@ -1033,8 +1034,7 @@ int main() { // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. - TheModule->setDataLayout(TheExecutionEngine->getDataLayout()); - OurFPM.add(new DataLayoutPass()); + TheModule->setDataLayout(*TheExecutionEngine->getDataLayout()); // Provide basic AliasAnalysis support for GVN. OurFPM.add(createBasicAliasAnalysisPass()); // Do simple "peephole" optimizations and bit-twiddling optzns. diff --git a/examples/Kaleidoscope/Chapter7/toy.cpp b/examples/Kaleidoscope/Chapter7/toy.cpp index 82f083a..ce5e1dd 100644 --- a/examples/Kaleidoscope/Chapter7/toy.cpp +++ b/examples/Kaleidoscope/Chapter7/toy.cpp @@ -1,3 +1,4 @@ +#include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/Passes.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/MCJIT.h" @@ -1207,8 +1208,7 @@ int main() { // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. - TheModule->setDataLayout(TheExecutionEngine->getDataLayout()); - OurFPM.add(new DataLayoutPass()); + TheModule->setDataLayout(*TheExecutionEngine->getDataLayout()); // Provide basic AliasAnalysis support for GVN. OurFPM.add(createBasicAliasAnalysisPass()); // Promote allocas to registers. diff --git a/examples/Kaleidoscope/Chapter8/toy.cpp b/examples/Kaleidoscope/Chapter8/toy.cpp index 30d4669..39b6a65 100644 --- a/examples/Kaleidoscope/Chapter8/toy.cpp +++ b/examples/Kaleidoscope/Chapter8/toy.cpp @@ -1,3 +1,4 @@ +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Triple.h" #include "llvm/Analysis/Passes.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" @@ -1458,8 +1459,7 @@ int main() { // Set up the optimizer pipeline. Start with registering info about how the // target lays out data structures. - TheModule->setDataLayout(TheExecutionEngine->getDataLayout()); - OurFPM.add(new DataLayoutPass()); + TheModule->setDataLayout(*TheExecutionEngine->getDataLayout()); #if 0 // Provide basic AliasAnalysis support for GVN. OurFPM.add(createBasicAliasAnalysisPass()); diff --git a/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp b/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp index 2e65756..3b5dcd0 100644 --- a/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp +++ b/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp @@ -716,7 +716,7 @@ public: M(new Module(GenerateUniqueName("jit_module_"), Session.getLLVMContext())), Builder(Session.getLLVMContext()) { - M->setDataLayout(Session.getTarget().getDataLayout()); + M->setDataLayout(*Session.getTarget().getDataLayout()); } SessionContext& getSession() { return Session; } @@ -1185,7 +1185,8 @@ public: return MangledName; } - void addFunctionDefinition(std::unique_ptr FnAST) { + void addFunctionAST(std::unique_ptr FnAST) { + std::cerr << "Adding AST: " << FnAST->Proto->Name << "\n"; FunctionDefs[mangle(FnAST->Proto->Name)] = std::move(FnAST); } @@ -1201,7 +1202,7 @@ public: // If we don't already have a definition of 'Name' then search // the ASTs. - return searchUncompiledASTs(Name); + return searchFunctionASTs(Name); }, [](const std::string &S) { return 0; } ); @@ -1231,20 +1232,18 @@ private: // This method searches the FunctionDefs map for a definition of 'Name'. If it // finds one it generates a stub for it and returns the address of the stub. - TargetAddress searchUncompiledASTs(const std::string &Name) { + TargetAddress searchFunctionASTs(const std::string &Name) { auto DefI = FunctionDefs.find(Name); if (DefI == FunctionDefs.end()) return 0; - // We have AST for 'Name'. IRGen a stub for it and add it to the JIT. - // FIXME: What happens if IRGen fails? - auto H = irGenStub(std::move(DefI->second)); - - // Remove the function definition's AST now that we're - // finished with it. + // Return the address of the stub. + // Take the FunctionAST out of the map. + auto FnAST = std::move(DefI->second); FunctionDefs.erase(DefI); - // Return the address of the stub. + // IRGen the AST, add it to the JIT, and return the address for it. + auto H = irGenStub(std::move(FnAST)); return findSymbolIn(H, Name).getAddress(); } @@ -1291,7 +1290,7 @@ private: return findUnmangledSymbolIn(H, Fn->Proto->Name).getAddress(); }); CallbackInfo.setUpdateAction( - CompileCallbacks.getLocalFPUpdater(H, mangle(BodyPtrName))); + getLocalFPUpdater(LazyEmitLayer, H, mangle(BodyPtrName))); return H; } @@ -1310,7 +1309,7 @@ private: static void HandleDefinition(SessionContext &S, KaleidoscopeJIT &J) { if (auto F = ParseDefinition()) { S.addPrototypeAST(llvm::make_unique(*F->Proto)); - J.addFunctionDefinition(std::move(F)); + J.addFunctionAST(std::move(F)); } else { // Skip token for error recovery. getNextToken(); diff --git a/examples/Kaleidoscope/Orc/initial/toy.cpp b/examples/Kaleidoscope/Orc/initial/toy.cpp index 1b65e8c..cc6fb8e 100644 --- a/examples/Kaleidoscope/Orc/initial/toy.cpp +++ b/examples/Kaleidoscope/Orc/initial/toy.cpp @@ -715,7 +715,7 @@ public: M(new Module(GenerateUniqueName("jit_module_"), Session.getLLVMContext())), Builder(Session.getLLVMContext()) { - M->setDataLayout(Session.getTarget().getDataLayout()); + M->setDataLayout(*Session.getTarget().getDataLayout()); } SessionContext& getSession() { return Session; } diff --git a/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp b/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp index 1ed267d..6e2ec27 100644 --- a/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp +++ b/examples/Kaleidoscope/Orc/lazy_codegen/toy.cpp @@ -715,7 +715,7 @@ public: M(new Module(GenerateUniqueName("jit_module_"), Session.getLLVMContext())), Builder(Session.getLLVMContext()) { - M->setDataLayout(Session.getTarget().getDataLayout()); + M->setDataLayout(*Session.getTarget().getDataLayout()); } SessionContext& getSession() { return Session; } diff --git a/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp b/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp index d7744ec..19801e1 100644 --- a/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp +++ b/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp @@ -715,7 +715,7 @@ public: M(new Module(GenerateUniqueName("jit_module_"), Session.getLLVMContext())), Builder(Session.getLLVMContext()) { - M->setDataLayout(Session.getTarget().getDataLayout()); + M->setDataLayout(*Session.getTarget().getDataLayout()); } SessionContext& getSession() { return Session; } @@ -1174,7 +1174,8 @@ public: return MangledName; } - void addFunctionDefinition(std::unique_ptr FnAST) { + void addFunctionAST(std::unique_ptr FnAST) { + std::cerr << "Adding AST: " << FnAST->Proto->Name << "\n"; FunctionDefs[mangle(FnAST->Proto->Name)] = std::move(FnAST); } @@ -1190,7 +1191,7 @@ public: // If we don't already have a definition of 'Name' then search // the ASTs. - return searchUncompiledASTs(Name); + return searchFunctionASTs(Name); }, [](const std::string &S) { return 0; } ); @@ -1216,21 +1217,17 @@ private: // This method searches the FunctionDefs map for a definition of 'Name'. If it // finds one it generates a stub for it and returns the address of the stub. - TargetAddress searchUncompiledASTs(const std::string &Name) { + TargetAddress searchFunctionASTs(const std::string &Name) { auto DefI = FunctionDefs.find(Name); if (DefI == FunctionDefs.end()) return 0; - // We have AST for 'Name'. IRGen it, add it to the JIT, and - // return the address for it. - // FIXME: What happens if IRGen fails? - auto H = addModule(IRGen(Session, *DefI->second)); - - // Remove the function definition's AST now that we're - // finished with it. + // Take the FunctionAST out of the map. + auto FnAST = std::move(DefI->second); FunctionDefs.erase(DefI); - // Return the address of the function. + // IRGen the AST, add it to the JIT, and return the address for it. + auto H = addModule(IRGen(Session, *FnAST)); return findSymbolIn(H, Name).getAddress(); } @@ -1246,7 +1243,7 @@ private: static void HandleDefinition(SessionContext &S, KaleidoscopeJIT &J) { if (auto F = ParseDefinition()) { S.addPrototypeAST(llvm::make_unique(*F->Proto)); - J.addFunctionDefinition(std::move(F)); + J.addFunctionAST(std::move(F)); } else { // Skip token for error recovery. getNextToken(); diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp index 4ebf3d0..b2c53a9 100644 --- a/examples/ParallelJIT/ParallelJIT.cpp +++ b/examples/ParallelJIT/ParallelJIT.cpp @@ -17,6 +17,7 @@ // call into the JIT at the same time (or the best possible approximation of the // same time). This test had assertion errors until I got the locking right. +#include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/IR/Constants.h" -- cgit v1.1