summaryrefslogtreecommitdiffstats
path: root/llvm/docs/tutorial/LangImpl7.html
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2009-08-26 20:58:25 +0000
committerReid Kleckner <reid@kleckner.net>2009-08-26 20:58:25 +0000
commitab7700479f64d7badfe3b822226dfbbb12edc719 (patch)
tree2228b92334b8f50c7d4d55312f2a21486b252278 /llvm/docs/tutorial/LangImpl7.html
parenta5588bf3acab74e44f47825f8351cb415f5fe42f (diff)
downloadbcm5719-llvm-ab7700479f64d7badfe3b822226dfbbb12edc719.tar.gz
bcm5719-llvm-ab7700479f64d7badfe3b822226dfbbb12edc719.zip
Allocate the module provider in the Kaleidoscope code on the heap, not the stack, so that it can be properly deleted. Also update the tutorial with the new code. This fixes PR4762, hopefully better than the last time.
llvm-svn: 80138
Diffstat (limited to 'llvm/docs/tutorial/LangImpl7.html')
-rw-r--r--llvm/docs/tutorial/LangImpl7.html61
1 files changed, 29 insertions, 32 deletions
diff --git a/llvm/docs/tutorial/LangImpl7.html b/llvm/docs/tutorial/LangImpl7.html
index 81386bc1ab0..90925a904f8 100644
--- a/llvm/docs/tutorial/LangImpl7.html
+++ b/llvm/docs/tutorial/LangImpl7.html
@@ -2101,41 +2101,38 @@ int main() {
// Make the module, which holds all the code.
TheModule = new Module("my cool jit", getGlobalContext());
-
- // Create the JIT.
- TheExecutionEngine = EngineBuilder(TheModule).create();
- {
- ExistingModuleProvider OurModuleProvider(TheModule);
- FunctionPassManager OurFPM(&amp;OurModuleProvider);
-
- // Set up the optimizer pipeline. Start with registering info about how the
- // target lays out data structures.
- OurFPM.add(new TargetData(*TheExecutionEngine-&gt;getTargetData()));
- // Promote allocas to registers.
- OurFPM.add(createPromoteMemoryToRegisterPass());
- // Do simple "peephole" optimizations and bit-twiddling optzns.
- OurFPM.add(createInstructionCombiningPass());
- // Reassociate expressions.
- OurFPM.add(createReassociatePass());
- // Eliminate Common SubExpressions.
- OurFPM.add(createGVNPass());
- // Simplify the control flow graph (deleting unreachable blocks, etc).
- OurFPM.add(createCFGSimplificationPass());
+ ExistingModuleProvider *OurModuleProvider =
+ new ExistingModuleProvider(TheModule);
- // Set the global so the code gen can use this.
- TheFPM = &amp;OurFPM;
+ // Create the JIT. This takes ownership of the module and module provider.
+ TheExecutionEngine = EngineBuilder(OurModuleProvider).create();
+
+ FunctionPassManager OurFPM(OurModuleProvider);
+
+ // Set up the optimizer pipeline. Start with registering info about how the
+ // target lays out data structures.
+ OurFPM.add(new TargetData(*TheExecutionEngine-&gt;getTargetData()));
+ // Do simple "peephole" optimizations and bit-twiddling optzns.
+ OurFPM.add(createInstructionCombiningPass());
+ // Reassociate expressions.
+ OurFPM.add(createReassociatePass());
+ // Eliminate Common SubExpressions.
+ OurFPM.add(createGVNPass());
+ // Simplify the control flow graph (deleting unreachable blocks, etc).
+ OurFPM.add(createCFGSimplificationPass());
+
+ // Set the global so the code gen can use this.
+ TheFPM = &amp;OurFPM;
+
+ // Run the main "interpreter loop" now.
+ MainLoop();
+
+ TheFPM = 0;
+
+ // Print out all of the generated code.
+ TheModule-&gt;dump();
- // Run the main "interpreter loop" now.
- MainLoop();
-
- TheFPM = 0;
-
- // Print out all of the generated code.
- TheModule-&gt;dump();
-
- } // Free module provider (and thus the module) and pass manager.
-
return 0;
}
</pre>
OpenPOWER on IntegriCloud