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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 22 13:51:04 PST 2019


+Lang

On Wed, Jan 16, 2019 at 4:58 AM Damian Smith via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> 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.
>
> Here is the diff from git 5aae26ab876 :
>
> diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp
> b/examples/HowToUseJIT/HowToUseJIT.cpp
> index f141fa5a7f5..a0ec57a1f51 100644
> --- a/examples/HowToUseJIT/HowToUseJIT.cpp
> +++ b/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"
> diff --git a/examples/Kaleidoscope/Chapter4/CMakeLists.txt
> b/examples/Kaleidoscope/Chapter4/CMakeLists.txt
> index fdc083e0768..599e19fba8d 100644
> --- a/examples/Kaleidoscope/Chapter4/CMakeLists.txt
> +++ b/examples/Kaleidoscope/Chapter4/CMakeLists.txt
> @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
>    Analysis
>    Core
>    ExecutionEngine
> +  Interpreter
>    InstCombine
>    Object
>    OrcJIT
> diff --git a/examples/Kaleidoscope/Chapter5/CMakeLists.txt
> b/examples/Kaleidoscope/Chapter5/CMakeLists.txt
> index 757d901ef52..aa6cbc0ebf9 100644
> --- a/examples/Kaleidoscope/Chapter5/CMakeLists.txt
> +++ b/examples/Kaleidoscope/Chapter5/CMakeLists.txt
> @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
>    Analysis
>    Core
>    ExecutionEngine
> +  Interpreter
>    InstCombine
>    Object
>    OrcJIT
> diff --git a/examples/Kaleidoscope/Chapter6/CMakeLists.txt
> b/examples/Kaleidoscope/Chapter6/CMakeLists.txt
> index ad50928a346..84ce6d26e4f 100644
> --- a/examples/Kaleidoscope/Chapter6/CMakeLists.txt
> +++ b/examples/Kaleidoscope/Chapter6/CMakeLists.txt
> @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
>    Analysis
>    Core
>    ExecutionEngine
> +  Interpreter
>    InstCombine
>    Object
>    OrcJIT
> diff --git a/examples/Kaleidoscope/Chapter7/CMakeLists.txt
> b/examples/Kaleidoscope/Chapter7/CMakeLists.txt
> index 03220358ab7..d3fe2d78e25 100644
> --- a/examples/Kaleidoscope/Chapter7/CMakeLists.txt
> +++ b/examples/Kaleidoscope/Chapter7/CMakeLists.txt
> @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
>    Analysis
>    Core
>    ExecutionEngine
> +  Interpreter
>    InstCombine
>    Object
>    OrcJIT
> diff --git a/examples/Kaleidoscope/Chapter9/CMakeLists.txt
> b/examples/Kaleidoscope/Chapter9/CMakeLists.txt
> index 565a7ffd32e..83544874f7f 100644
> --- a/examples/Kaleidoscope/Chapter9/CMakeLists.txt
> +++ b/examples/Kaleidoscope/Chapter9/CMakeLists.txt
> @@ -1,6 +1,7 @@
>  set(LLVM_LINK_COMPONENTS
>    Core
>    ExecutionEngine
> +  Interpreter
>    Object
>    OrcJIT
>    Support
> diff --git a/examples/Kaleidoscope/include/KaleidoscopeJIT.h
> b/examples/Kaleidoscope/include/KaleidoscopeJIT.h
> index 972773a64f7..dc42d599c2f 100644
> --- a/examples/Kaleidoscope/include/KaleidoscopeJIT.h
> +++ b/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 @@ public:
>        : 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()),
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190122/5867aec7/attachment.html>


More information about the llvm-commits mailing list