Frank Winter via llvm-dev
2019-Mar-26 20:36 UTC
[llvm-dev] ORC JIT fails with standard math librrary
Hi, I still can't get IR functions to JIT compile with the ORC JIT when they contain a call to the standard math library. Attached is a minimal exploit. The program uses the KaleidoscopeJIT.h that ships with LLVM 8 (except that I had to expose the Datalayout). It reads from the filesystem an IR file (filename "func_works.ll" or "func_cos_fails.ll) and asks the ORC JIT first for the symbol "func_ir" and then for the address. In case the file "func_works.ll" was read the program succeeds with: symbol found! address found! In case the file "func_cos_fails.ll" was read the program fails with: symbol found! Failure value returned from cantFail wrapped call UNREACHABLE executed at install/llvm-8.0-x86-debug/include/llvm/Support/Error.h:732! Stack dump: This was tested on an x86 Linux Ubuntu system. Does anyone see what's going on or is it time to file a bug report? Regards, Frank -------------- next part -------------- source_filename = "module" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" declare float @cosf(float) define float @func_ir(float %arg0) { entrypoint: %0 = call float @cosf(float %arg0) ret float %0 } -------------- next part -------------- source_filename = "module" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" define float @func_ir(float %arg0) { entrypoint: ret float %arg0 } -------------- next part -------------- A non-text attachment was scrubbed... Name: KaleidoscopeJIT.h Type: text/x-chdr Size: 5065 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190326/10780d64/attachment.h> -------------- next part -------------- LLVM_CONFIG = /home/fwinter/toolchain/install/llvm-8.0-x86-debug/bin/llvm-config LLVM_CXXFLAGS = $(shell $(LLVM_CONFIG) --cxxflags) LLVM_LDFLAGS = $(shell $(LLVM_CONFIG) --ldflags) LLVM_LIBS = $(shell $(LLVM_CONFIG) --libs) all: test test.o: test.cc KaleidoscopeJIT.h g++ -c -o $@ $< $(LLVM_CXXFLAGS) test: test.o g++ -o $@ $< $(LLVM_LDFLAGS) $(LLVM_LIBS) clean: rm -f *.o rm -f test -------------- next part -------------- A non-text attachment was scrubbed... Name: test.cc Type: text/x-c++src Size: 2060 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190326/10780d64/attachment.cc>
Lang Hames via llvm-dev
2019-May-07 01:56 UTC
[llvm-dev] ORC JIT fails with standard math librrary
I see the problem: The KaleidoscopeJIT in this example isn't searching process symbols. This leads to a "symbol not found" failure when we try to look up math functions, but due to the way legacy ORC lookup works this manifests as a "failure to materialize symbols" error when we try to materialize a function that uses these symbols, rather than a plain "symbol not found" error. I should be able to fix this up tomorrow, and the issue will go away entirely once the tutorials are moved on to concurrent ORC. -- Lang. On Tue, Mar 26, 2019 at 1:37 PM Frank Winter via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > > I still can't get IR functions to JIT compile with the ORC JIT when they > contain a call to the standard math library. Attached is a minimal exploit. > > The program uses the KaleidoscopeJIT.h that ships with LLVM 8 (except > that I had to expose the Datalayout). It reads from the filesystem an IR > file (filename "func_works.ll" or "func_cos_fails.ll) and asks the ORC > JIT first for the symbol "func_ir" and then for the address. > > In case the file "func_works.ll" was read the program succeeds with: > > symbol found! > address found! > > In case the file "func_cos_fails.ll" was read the program fails with: > > symbol found! > Failure value returned from cantFail wrapped call > UNREACHABLE executed at > install/llvm-8.0-x86-debug/include/llvm/Support/Error.h:732! > Stack dump: > > This was tested on an x86 Linux Ubuntu system. > > Does anyone see what's going on or is it time to file a bug report? > > > Regards, > > Frank > > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190506/800d6cd3/attachment.html>
Lang Hames via llvm-dev
2019-May-08 20:48 UTC
[llvm-dev] ORC JIT fails with standard math librrary
Hi Frank, It looks like this was fixed already in r354598. The solution was to resolve symbols by calling findMangledSymbol (which searches the process symbols via RTDyldMemoryManager::getSymbolAddressInProcess) instead of ObjLayer.findSymbol (which only searches JIT'd code). Cheers, Lang. On Mon, May 6, 2019 at 6:56 PM Lang Hames <lhames at gmail.com> wrote:> I see the problem: The KaleidoscopeJIT in this example isn't searching > process symbols. This leads to a "symbol not found" failure when we try to > look up math functions, but due to the way legacy ORC lookup works this > manifests as a "failure to materialize symbols" error when we try to > materialize a function that uses these symbols, rather than a plain "symbol > not found" error. > > I should be able to fix this up tomorrow, and the issue will go away > entirely once the tutorials are moved on to concurrent ORC. > > -- Lang. > > On Tue, Mar 26, 2019 at 1:37 PM Frank Winter via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi, >> >> I still can't get IR functions to JIT compile with the ORC JIT when they >> contain a call to the standard math library. Attached is a minimal >> exploit. >> >> The program uses the KaleidoscopeJIT.h that ships with LLVM 8 (except >> that I had to expose the Datalayout). It reads from the filesystem an IR >> file (filename "func_works.ll" or "func_cos_fails.ll) and asks the ORC >> JIT first for the symbol "func_ir" and then for the address. >> >> In case the file "func_works.ll" was read the program succeeds with: >> >> symbol found! >> address found! >> >> In case the file "func_cos_fails.ll" was read the program fails with: >> >> symbol found! >> Failure value returned from cantFail wrapped call >> UNREACHABLE executed at >> install/llvm-8.0-x86-debug/include/llvm/Support/Error.h:732! >> Stack dump: >> >> This was tested on an x86 Linux Ubuntu system. >> >> Does anyone see what's going on or is it time to file a bug report? >> >> >> Regards, >> >> Frank >> >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190508/1eb30cc3/attachment.html>