[llvm-dev] ORC JIT - different behaviour of ExecutionSession.lookup?
Gaier, Bjoern via llvm-dev
llvm-dev at lists.llvm.org
Mon Sep 28 04:57:09 PDT 2020
Hey everyone,
I felt this question is different from my other question - hope this is okay.
So - I was playing around with the lookup function of the ExecutionSession and there are some things I don't understand.
I have a .BC file with a function "?Sampler@@YAXXZ" referencing a value "?_Plansch_test@@3HA" that is not defined in that module itself. I first planed on not providing an address for "?_Plansch_test@@3HA" but wanted to know the address of "?Sampler@@YAXXZ". So I issued something like that:
auto &ES = this->jit->getExecutionSession();
SymbolLookupSet lookupSet;
lookupSet.add("?Sampler@@YAXXZ", llvm::orc::SymbolLookupFlags::WeaklyReferencedSymbol);
ES.lookup({{&jit->getMainJITDylib(), llvm::orc::JITDylibLookupFlags::MatchAllSymbols}}, lookupSet, llvm::orc::LookupKind::Static, llvm::orc::SymbolState::Resolved);
Even though the "tryToGenerate" function of my DefinitionGenerator returned a "llvm::orc::SymbolsNotFound" for the "?_Plansch_test@@3HA", I got an address for "?Sampler@@YAXXZ". Dumping the "MainJITDylib" I saw, that the "?Sampler@@YAXXZ" was in an Error state. Which made sense - I guess.
Question 1.)
Is there any way to reset the error state of "?Sampler@@YAXXZ" at this point?
- After my first call I used the "define" function of the JITDylib to define ?_Plansch_test@@3HA and then I tried calling the lookup function again and again, however I only got the error: "Failed to materialize symbols" even though "?_Plansch_test@@3HA" was defined now...
- Changing the order of the "define" and the "lookup" call works of course, but I'm interested in the case where I don't know the address yet.
Out of curiosity I repeated the previous scenario - but added "?_Plansch_test@@3HA" to the "lookupSet" which changed things drasticly. When executing "lookup" I now get the "llvm::orc::SymbolsNotFound" error from my DefinitionGenerator and "?Sampler@@YAXXZ" is stuck as a pending query in the MaterializingInfos entries. When I then add a definition for "?_Plansch_test@@3HA" and call "lookup" the second time, it will succeed and give me the addresses. Also I'm able to execute the code now. This is great! However...
Question 2.)
Why did the first call to lookup not return the address of "?Sampler@@YAXXZ" like in the first scenario? I expected it would return an address for it.
Question 3.)
Can I somehow combine both behaviours? Getting the address for all the symbols (like in scenario 1) while still being able to provide definitions later (like in scenario 2)?
Thank you in advance and kind greetings,
Björn
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200928/471bf9ca/attachment.html>
More information about the llvm-dev
mailing list