<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Yes, I think ordering was a problem.
I've moved my target machine setup to immediately after creating
the `Module` now, before adding any IR, and it seems to work.<br>
<br>
   module = new llvm::Module( "test", *llvm_context );<br>
   module->setTargetTriple( platform::target->triple );<br>
   <br>
   std::string err_str;<br>
   auto triple_str =
llvm::Triple::normalize(platform::target->triple);<br>
   llvm::Target const * target =
llvm::TargetRegistry::lookupTarget( triple_str, err_str );<br>
   STATE_CHECK( target, err_str );<br>
   auto targetMachine =
target->createTargetMachine(triple_str, "generic", "",
llvm::TargetOptions{}, <br>
      llvm::Optional<llvm::Reloc::Model>());<br>
   <br>
   module->setDataLayout( targetMachine->createDataLayout()
);<br>
<br>
<br>
On 19/04/18 21:52, Lang Hames wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CALLttgqEQ+zt_hgZwSz7jN7AxKBKV+9jBUB7XTT2uEn7RuB4Zg@mail.gmail.com">
<div dir="ltr">Hi edaqa,
<div><br>
</div>
<div>You might need to set your TargetOptions before calling
selectTarget. E.g.</div>
<div><br>
</div>
<div><font face="monospace, monospace">builder.setTargetOptions(Opts).selectTarget(...);</font></div>
<div><br>
</div>
<div>Or you could just let EngineBuilder call selectTarget for
you (which is what the no-argument version of
EngineBuilder::create does):</div>
<div><span
style="font-size:12.800000190734863px;font-family:monospace,monospace"><br>
</span></div>
<div><span
style="font-size:12.800000190734863px;font-family:monospace,monospace">llvm::ExecutionEngine
* ee = builder.</span><br>
</div>
<div><font face="monospace, monospace"><span
style="font-size:12.800000190734863px">Â Â Â Â Â Â
setErrorStr( &errStr ).</span><br
style="font-size:12.800000190734863px">
<span style="font-size:12.800000190734863px">Â Â Â Â Â Â
setEngineKind( llvm::EngineKind::JIT ).</span><br
style="font-size:12.800000190734863px">
<span style="font-size:12.800000190734863px">Â Â Â Â Â Â
setTargetOptions( topts ).</span></font></div>
<div><font face="monospace, monospace">Â Â Â Â setMArch(arch).</font></div>
<div><font face="monospace, monospace">Â Â Â Â
setMAttrs(mattrs).</font></div>
<div><font face="monospace, monospace"><span
style="font-size:12.800000190734863px">Â Â Â Â Â Â create(</span><span
style="font-size:12.800000190734863px">);</span></font></div>
<div><br>
</div>
<div>If those are still failing, it would be interesting to get
the data layout string that you are getting from the
ExecutionEngine instance and compare it to what you are
expecting.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Lang.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Apr 19, 2018 at 1:56 AM, edA-qa
mort-ora-y via llvm-dev <span dir="ltr"><<a
href="mailto:llvm-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Taking one
step back, I'm not clear I'm even setting the<br>
triple/DataLayout on the module correctly:<br>
<br>
   module = new llvm::Module( "test", *llvm_context );<br>
   module->setTargetTriple( platform::target->triple
);<br>
<br>
Is that enough to create an appropriate DataLayout for the
module? I<br>
don't see anyway to convert a triple to a DataLayout, so I
can't call<br>
`setDataLayout`.<br>
<div class="HOEnZb">
<div class="h5"><br>
<br>
On 19/04/18 10:44, edA-qa mort-ora-y via llvm-dev wrote:<br>
> I don't know if I'm setting the triple of my
execution engine<br>
> correctly. This is leading to an issue where a
struct `{i8,i64}` is not<br>
> getting the same layout as the ABI expects.<br>
><br>
> I setup my engine/module like this:<br>
><br>
> Â Â Â Â llvm::SmallVector<std::string,<wbr>2>
mattrs;<br>
> Â Â Â Â llvm::EngineBuilder builder{
unique_ptr<llvm::Module>(<wbr>module) };<br>
> Â Â Â llvm::ExecutionEngine * ee = builder.<br>
> Â Â Â Â Â Â setErrorStr( &errStr ).<br>
> Â Â Â Â Â Â setEngineKind( llvm::EngineKind::JIT ).<br>
> Â Â Â Â Â Â setTargetOptions( topts ).<br>
> Â Â Â Â Â Â create(builder.selectTarget(<br>
> llvm::Triple(llvm::Triple::<wbr>normalize(platform::target-><wbr>triple)),
"", "",<br>
> mattrs ));<br>
><br>
> Â Â Â module->setDataLayout(
ee->getDataLayout() );<br>
><br>
> Where `module` is my `llvm::Module` with the
generated IR code.<br>
><br>
> I'm using the triple `x86_64-pc-linux-gnu`, the
same as clang on the<br>
> machine, but getting different alignments. I'm
assuming the above is<br>
> somehow not creating the correct layout. Perhaps
there's an ordering issue?<br>
><br>
<br>
-- <br>
edA-qa mort-ora-y <br>
    <a href="http://mortoray.com/" rel="noreferrer"
target="_blank" moz-do-not-send="true">http://mortoray.com/</a><br>
<br>
Creator of the Leaf language<br>
    <a href="http://leaflang.org/" rel="noreferrer"
target="_blank" moz-do-not-send="true">http://leaflang.org/</a><br>
<br>
Streaming algorithms, AI, and design on Twitch<br>
    <a href="https://www.twitch.tv/mortoray"
rel="noreferrer" target="_blank"
moz-do-not-send="true">https://www.twitch.tv/mortoray</a><br>
<br>
Twitter<br>
    edaqa<br>
<br>
<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
rel="noreferrer" target="_blank"
moz-do-not-send="true">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
<pre class="moz-signature" cols="72">--
edA-qa mort-ora-y
<a class="moz-txt-link-freetext" href="http://mortoray.com/">http://mortoray.com/</a>
Creator of the Leaf language
<a class="moz-txt-link-freetext" href="http://leaflang.org/">http://leaflang.org/</a>
Streaming algorithms, AI, and design on Twitch
<a class="moz-txt-link-freetext" href="https://www.twitch.tv/mortoray">https://www.twitch.tv/mortoray</a>
Twitter
edaqa
</pre>
</body>
</html>