[PATCH] D56973: [Orc] Resolve crashes in the examples HowToUsejit and Kaleidoscope-Ch4, Kaleidoscope-Ch5, ..., Kaleidoscope-Ch9

Damian Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 19 22:12:51 PST 2019


damian created this revision.
Herald added a subscriber: mgorny.

This is my first review!!

When following the tutorial and came to Kaleidoscope chapter4 the code was crashing when running the following code:
def testfunc(x y) x + y*2;
testfunc(4, 10);

I then patched the code:

1. Make sure ForceInterpreterLinking is defined, to avoid an error "interpreter has not been linked".
2. When Finding the symbol we only looked for external functions in Kaleidoscope.

After that the code does on no longer crash.

There is still an issue when entering empty strings, but I a fix for this might come later.


Repository:
  rL LLVM

https://reviews.llvm.org/D56973

Files:
  examples/HowToUseJIT/HowToUseJIT.cpp
  examples/Kaleidoscope/Chapter4/CMakeLists.txt
  examples/Kaleidoscope/Chapter5/CMakeLists.txt
  examples/Kaleidoscope/Chapter6/CMakeLists.txt
  examples/Kaleidoscope/Chapter7/CMakeLists.txt
  examples/Kaleidoscope/Chapter9/CMakeLists.txt
  examples/Kaleidoscope/include/KaleidoscopeJIT.h


Index: examples/Kaleidoscope/include/KaleidoscopeJIT.h
===================================================================
--- examples/Kaleidoscope/include/KaleidoscopeJIT.h
+++ examples/Kaleidoscope/include/KaleidoscopeJIT.h
@@ -24,6 +24,7 @@
 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
+#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Mangler.h"
 #include "llvm/Support/DynamicLibrary.h"
@@ -47,7 +48,7 @@
       : Resolver(createLegacyLookupResolver(
             ES,
             [this](const std::string &Name) {
-              return ObjectLayer.findSymbol(Name, true);
+              return ObjectLayer.findSymbol(Name, false);
             },
             [](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })),
         TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
Index: examples/Kaleidoscope/Chapter9/CMakeLists.txt
===================================================================
--- examples/Kaleidoscope/Chapter9/CMakeLists.txt
+++ examples/Kaleidoscope/Chapter9/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   Core
   ExecutionEngine
+  Interpreter
   Object
   OrcJIT
   Support
Index: examples/Kaleidoscope/Chapter7/CMakeLists.txt
===================================================================
--- examples/Kaleidoscope/Chapter7/CMakeLists.txt
+++ examples/Kaleidoscope/Chapter7/CMakeLists.txt
@@ -2,6 +2,7 @@
   Analysis
   Core
   ExecutionEngine
+  Interpreter
   InstCombine
   Object
   OrcJIT
Index: examples/Kaleidoscope/Chapter6/CMakeLists.txt
===================================================================
--- examples/Kaleidoscope/Chapter6/CMakeLists.txt
+++ examples/Kaleidoscope/Chapter6/CMakeLists.txt
@@ -2,6 +2,7 @@
   Analysis
   Core
   ExecutionEngine
+  Interpreter
   InstCombine
   Object
   OrcJIT
Index: examples/Kaleidoscope/Chapter5/CMakeLists.txt
===================================================================
--- examples/Kaleidoscope/Chapter5/CMakeLists.txt
+++ examples/Kaleidoscope/Chapter5/CMakeLists.txt
@@ -2,6 +2,7 @@
   Analysis
   Core
   ExecutionEngine
+  Interpreter
   InstCombine
   Object
   OrcJIT
Index: examples/Kaleidoscope/Chapter4/CMakeLists.txt
===================================================================
--- examples/Kaleidoscope/Chapter4/CMakeLists.txt
+++ examples/Kaleidoscope/Chapter4/CMakeLists.txt
@@ -2,6 +2,7 @@
   Analysis
   Core
   ExecutionEngine
+  Interpreter
   InstCombine
   Object
   OrcJIT
Index: examples/HowToUseJIT/HowToUseJIT.cpp
===================================================================
--- examples/HowToUseJIT/HowToUseJIT.cpp
+++ examples/HowToUseJIT/HowToUseJIT.cpp
@@ -37,6 +37,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/ExecutionEngine/Interpreter.h"
 #include "llvm/IR/Argument.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constants.h"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56973.182693.patch
Type: text/x-patch
Size: 3115 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190120/d4599b10/attachment.bin>


More information about the llvm-commits mailing list