<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hello Chris,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The Orc API sounds interesting – are there helpful tutorials or examples available? The only one I found is the Kaleidoscope tutorial but I had difficulties in the past following that tutorial.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Kind greetings<o:p></o:p></p>
<p class="MsoNormal">Björn<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Chris Bieneman <chris.bieneman@me.com> <br>
<b>Sent:</b> Freitag, 10. Mai 2019 20:55<br>
<b>To:</b> Gaier, Bjoern <Bjoern.Gaier@horiba.com><br>
<b>Cc:</b> preejackie <praveenvelliengiri@gmail.com>; llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm-dev] Reuse llvm::ExecutionEngine<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I'm by no means an expert on the JIT layers, but ExecutionEngine is an abstract interface. In theory, each implementation of that interface should function similarly, but in practice YMMV. You're using MCJIT, which is the older JIT flow
 which is not getting a lot of attention these days. You might get further if you switch to using the OrcMCJITReplacement, or migrate to the Orc APIs more generally.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">There are some very handy new interfaces in the Orc APIs, like the LLJIT classes which get things going pretty easy. I've been using LLJIT in my project, and it is really easy to setup, keep around and add multiple IR modules to.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-Chris<o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On May 7, 2019, at 11:00 PM, Gaier, Bjoern via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal" style="background:white">Heyho,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">I can only provide you with a screenshot for the first problem I noticed:<br>
<image001.png><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">This code will crash when calling “eeBuilder.create”.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">But I also looked at what happens if I do reuse the llvm::ExecutionEngine. After the call to “finalizeObject” I use “removeModule” for the Module I used.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">If I know parse the same module again and pass it to that llvm::ExecutionEngine, it will notice the duplication and rename the symbols, like when it does when you add the same module two times.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">If I add a different module everything behaves as before – so overall it seems like you can’t reuse a llvm::ExecutionEngine…<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<div>
<p class="MsoNormal" style="background:white"><b>From:</b><span class="apple-converted-space"> </span>llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org"><span style="color:#954F72">llvm-dev-bounces@lists.llvm.org</span></a>><span class="apple-converted-space"> </span><b>On
 Behalf Of<span class="apple-converted-space"> </span></b>preejackie via llvm-dev<br>
<b>Sent:</b><span class="apple-converted-space"> </span>Dienstag, 7. Mai 2019 15:28<br>
<b>To:</b><span class="apple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org"><span style="color:#954F72">llvm-dev@lists.llvm.org</span></a><br>
<b>Subject:</b><span class="apple-converted-space"> </span>Re: [llvm-dev] Reuse llvm::ExecutionEngine<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:9.0pt;font-family:"Courier New"">Hi Bjoern,</span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:9.0pt;font-family:"Courier New"">Could you please give me a minimal code sample to produce this behavior?</span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p></o:p></span></p>
<div>
<div>
<p class="MsoNormal" style="background:white">On 07/05/19 5:17 PM, Gaier, Bjoern via llvm-dev wrote:<o:p></o:p></p>
</div>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="background:white"><span lang="DE">Dear LLVM-Mailing-List,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span lang="DE"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">I’m using the llvm::EngineBuilder to create an instance of the llvm::ExecutionEngine, I then JIT my code, take the addresses I need and delete the llvm::ExecutionEngine. But now I started to wonder, if I could reuse
 that instance for a new module again?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">I first tried calling llvm::EngineBuilder without setting a Module, I planned to add it later – but when I do this the “create” function will crash.<o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal" style="background:white">What crash you get? By quickly looking through interface, EngineBuilder uses nullptr if no module are provided.<span class="apple-converted-space"> </span><br>
<br>
<br>
<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">Another test I ran was calling “removeModule” of the llvm::ExecutionEngine  after the call to finalizeObject. Then I added the same module again and ran finalizeObject again. The result was weird, I suddenly became
 error messages about the relocation – I take this came because I applied a memory mapping in the first run.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">So to make it short: Is the llvm::ExecutionEngine designed for a reuse or is it better to create a new instance again?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">Kind greetings<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">Björn<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="background:white">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<span class="apple-converted-space"> </span><br>
<br>
<br>
<o:p></o:p></p>
</div>
<pre style="background:white">_______________________________________________<o:p></o:p></pre>
<pre style="background:white">LLVM Developers mailing list<o:p></o:p></pre>
<pre style="background:white"><a href="mailto:llvm-dev@lists.llvm.org"><span style="color:#954F72">llvm-dev@lists.llvm.org</span></a><o:p></o:p></pre>
<pre style="background:white"><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"><span style="color:#954F72">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</span></a><o:p></o:p></pre>
</blockquote>
<pre style="background:white">-- <o:p></o:p></pre>
<pre style="background:white">Have a great day!<o:p></o:p></pre>
<pre style="background:white">PreeJackie<o:p></o:p></pre>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;background:white">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_______________________________________________</span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<span style="background:white">LLVM Developers mailing list</span><br>
</span><a href="mailto:llvm-dev@lists.llvm.org"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72;background:white">llvm-dev@lists.llvm.org</span></a><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
</span><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;color:#954F72;background:white">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</span></a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
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
</body>
</html>