[llvm-dev] Questions after completed Kaleidoscope Chapter 1

Gaier, Bjoern via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 16 03:29:54 PDT 2019


Hey Praveen – and everyone else,

For 1.)
In my “Main.cpp” file I used
int (*function)() = (int(*)())jit->lookup("?helloOrc@@YAHXZ");

While the lookup looked like that:
uintptr_t lookup(StringRef Name)
{
       auto result = this->es.lookup({&this->es.getMainJITDylib()}, this->mangle(Name.str()));
       if(result)
       {
              return result->getAddress();
       }

       return 0x0;
}
Basically – it is the code from the tutorial, besides I wanted it to return an unintpr_t.
Anyway, if I remove “this->mangle(Name.str())” and use “Name.str()” instead - then it is still working. This is why I wonder, why that call is important.

A call like:
int (*function)() = (int(*)())jit->lookup("int helloOrc()");
Never worked.

For 2.)
I solved the problem by exporting the missing symbols, I just wanted to understand if the error is coming from the “DynamicLibrarySearchGenerator” and if I can silence it to keep my console output clean.

For 3.)
I understand that!

Thank you so much for this x3

Kind greetings
Björn

From: Praveen Velliengiri <praveenvelliengiri at gmail.com>
Sent: Donnerstag, 12. September 2019 19:51
To: David Blaikie <dblaikie at gmail.com>
Cc: Gaier, Bjoern <Bjoern.Gaier at horiba.com>; Lang Hames <lhames at gmail.com>; llvm-dev <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Questions after completed Kaleidoscope Chapter 1

Hi Bjoren,

For question 1:
As you mentioned, it is used to mangle to the symbol name and interning them, So ORC can find them at runtime in one of the JITDylibs. It would be helpful to know what you tried? (please attach code lines).

For question 2:
I guess you might be missing to link libraries that your program depend on, you can do that via setting up your dynamiclibrary search generator or getCurrentProcess symbols. Plus, Why do you want to hide them, it is an error?

For question 3:
Currently, every symbol whether it is added via generator or not, must be defined in a JITDylib. It is more of a design choice, it makes implementation and resolution logic much easier within ORC.

Thanks
Praveen


On Thu, 12 Sep 2019 at 22:56, David Blaikie via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote:
(adding Lang Hames, Orcish Scientist, for Orc-related queries)

On Thu, Sep 12, 2019 at 3:23 AM Gaier, Bjoern via llvm-dev
<llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote:
>
> Hello there,
>
>
>
> I finished Chapter 1 of the Kaleidoscope tutorial for using the Orc JIT API. I played around with some things and ended with some questions.
>
>
>
> What is the use of “MangleAndInterner”?
> I read it is used to mangle the name for the lookup search, but I seem to be not able to use it correctly. In my first attempt I used the mangled name of my function “?helloOrc@@YAHXZ” with the lookup method – that worked.
>
> Now I tried “int helloOrc()” and it failed/did not found the function. Then I tried “?helloOrc@@YAHXZ” again but removed the use of the “MangleAndInterner” instance – that worked again.
>
> What is that instance used for?
>
>
>
> JIT session error
>
> When I first run the JIT, the message “JIT session error: Symbols not found: { __security_check_cookie, __security_cookie }” was printed into the console.
>
> Origin
> Is that message coming from "DynamicLibrarySearchGenerator”?
>
>
>
> Redirect
> Can I somehow redirect this message to a string or something, or silence it? I want to keep my console output clean.
>
>
>
> Generator function
>
> Why does the generator function looks like this: “SymbolNameSet(JITDylib &Parent, const SymbolNameSet &Names)”?
>
> I understood, that the “Parent” will be the value from “ES.getMainJITDylib()” while “Names” will have the names that should be resolved. I saw an implementation for the Generator function that kinda looked like that:
> {
>
>       orc::SymbolNameSet Added;
>
>       orc::SymbolMap     NewSymbols;
>
>
>
>       for(auto &Name : Names)
>
>       {
>
>             Added.insert(Name);
>
>             NewSymbols[Name] = //Something
>
>       }
>
>
>
>       Parent.define(absoluteSymbols(std::move(NewSymbols)));
>
>       return Added;
>
> }
>
>
>
> I understood that “SymbolMap NewSymbols” will store a pair of name and the address to resolve – but why do I tell the JITDylib about this?
> And why do I also keep a map of the symbols I added and have to return them? (SymbolNameSet Added)
>
>
>
> I hope my questions are not too stupid and that someone can help me with that!
>
> Thank you a lot x3
>
>
>
> 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, Takeshi Fukushima. Junichi Tajika
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
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, Takeshi Fukushima. Junichi Tajika
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190916/03e386d4/attachment.html>


More information about the llvm-dev mailing list