aboutsummaryrefslogtreecommitdiffstats
path: root/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2015-04-10 22:08:18 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-10 22:08:18 +0000
commit13a7db5b9c4f5e543d037be68ec3428216bfd550 (patch)
tree1b2c9792582e12f5af0b1512e3094425f0dc0df9 /examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp
parent0eb46f5d1e06a4284663d636a74b06adc3a161d7 (diff)
parent31195f0bdca6ee2a5e72d07edf13e1d81206d949 (diff)
downloadexternal_llvm-13a7db5b9c4f5e543d037be68ec3428216bfd550.zip
external_llvm-13a7db5b9c4f5e543d037be68ec3428216bfd550.tar.gz
external_llvm-13a7db5b9c4f5e543d037be68ec3428216bfd550.tar.bz2
am 31195f0b: Merge "Update aosp/master llvm for rebase to r233350"
* commit '31195f0bdca6ee2a5e72d07edf13e1d81206d949': Update aosp/master llvm for rebase to r233350
Diffstat (limited to 'examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp')
-rw-r--r--examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp23
1 files changed, 10 insertions, 13 deletions
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<FunctionAST> FnAST) {
+ void addFunctionAST(std::unique_ptr<FunctionAST> 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<PrototypeAST>(*F->Proto));
- J.addFunctionDefinition(std::move(F));
+ J.addFunctionAST(std::move(F));
} else {
// Skip token for error recovery.
getNextToken();