summaryrefslogtreecommitdiffstats
path: root/llvm/examples
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2015-02-18 23:16:09 +0000
committerLang Hames <lhames@gmail.com>2015-02-18 23:16:09 +0000
commitfb605d28c4073cc08971bf825061b05302d931da (patch)
tree7a1493f6f5831a87a09bdf9db5714d9c24bc970a /llvm/examples
parented7cbb26e1ae701d99b6ca3cc12f5342d4501726 (diff)
downloadbcm5719-llvm-fb605d28c4073cc08971bf825061b05302d931da.tar.gz
bcm5719-llvm-fb605d28c4073cc08971bf825061b05302d931da.zip
[Orc][Kaleidoscope] Fix a fixme - no reason we can't use C++14 in the tutorials.
llvm-svn: 229765
Diffstat (limited to 'llvm/examples')
-rw-r--r--llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp b/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
index 3ef97998a2d..9210dd1f3bb 100644
--- a/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Orc/fully_lazy/toy.cpp
@@ -1253,18 +1253,21 @@ public:
// Step 4) Add the module containing the stub to the JIT.
auto H = addModule(C.takeM());
- // Step 5) Set the compile and update actions for the callback. The compile
- // action will IRGen and Codegen the function. The update action
- // will update FunctionBodyPointer to point at the newly compiled
- // function pointer.
+ // Step 5) Set the compile and update actions for the callback.
//
- // FIXME: Use generalized capture for FnAST when we get C++14 support.
- FunctionAST *FnASTPtr = FnAST.release();
- CallbackInfo.setCompileAction([this,FnASTPtr](){
- std::unique_ptr<FunctionAST> Fn(FnASTPtr);
- auto H = addModule(IRGen(Session, *Fn));
- return findSymbolIn(H, Fn->Proto->Name).getAddress();
- });
+ // The compile action will IRGen the function and add it to the JIT, then
+ // request its address, which will trigger codegen. Since we don't need the
+ // AST after this, we pass ownership of the AST into the compile action:
+ // compile actions (and update actions) are deleted after they're run, so
+ // this will free the AST for us.
+ //
+ // The update action will update FunctionBodyPointer to point at the newly
+ // compiled function.
+ CallbackInfo.setCompileAction(
+ [this,Fn = std::shared_ptr<FunctionAST>(std::move(FnAST))](){
+ auto H = addModule(IRGen(Session, *Fn));
+ return findSymbolIn(H, Fn->Proto->Name).getAddress();
+ });
CallbackInfo.setUpdateAction(
CompileCallbacks.getLocalFPUpdater(H, Mangle(BodyPtrName)));
}
OpenPOWER on IntegriCloud