<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">I think I've figured it out now. The
setup of my triple/datalayout for the module was apparently not
correct. It likely worked mainly to this point since the default
dataLayout is close to the host ABI, but not quite. <br>
<br>
I have the following setup, which appears to work:<br>
<br>
module = new llvm::Module( "test", *llvm_context );<br>
module->setTargetTriple( platform::target->triple );
//x86_64-pc-linux-gnu<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 ); //assert target != nullptr<br>
auto targetMachine =
target->createTargetMachine(triple_str, "generic", "",
llvm::TargetOptions{}, <br>
llvm::Optional<llvm::Reloc::Model>());<br>
<br>
module->setDataLayout( targetMachine->createDataLayout()
);<br>
<br>
I'll be testing on Mac later today, but I suspect it has the same
data layout.<br>
<br>
<br>
<br>
On 19/04/18 11:37, mats petersson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAL-htr6_vPkCDnyohWrd_Dxrnm+JD+SHdWUWpM_VsTd57+TVWQ@mail.gmail.com">
<div dir="ltr">
<div>What exactly is your alignment settings in your LLVM
struct?<br>
<br>
Something like this would tell you the alignment of
"something".<br>
<span class="gmail-pl-k">const</span> llvm::DataLayout <span
class="gmail-pl-smi">dl</span>(theModule);
<table class="gmail-highlight gmail-tab-size
gmail-js-file-line-container">
<tbody>
<tr>
<td id="gmail-LC23" class="gmail-blob-code
gmail-blob-code-inner gmail-js-file-line">size_t size
= dl.<span class="gmail-pl-c1">getPrefTypeAlignment</span>(something);<br>
</td>
</tr>
<tr>
</tr>
</tbody>
</table>
IIn "my" compiler, I don't do anything special to align
structs, so it's plausibly your specific data-layout that says
that i64 only needs aligning to 32-bits (and clang adjusts it
because "it can", by adding extra padding elements) - or
you're using different targets (or settings for the targets)<br>
</div>
<div><br>
--<br>
</div>
Mats<br>
<div>
<div class="gmail_extra">
<div class="gmail_quote">On 18 April 2018 at 21:47, 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">I
think I see a potential issue. My ExecutionEngine setup
may not be<br>
using the same target as my object code emitting, and in
this test case<br>
I'm running in the ExecutionEngine. I'll go over this
code to ensure<br>
I'm creating the same triple and see if that helps --
I'm assuming it<br>
will, since I can't imagine the exact same triple with
clang would<br>
produce a different layout.<br>
<span class="im HOEnZb"><br>
<br>
On 18/04/18 21:37, Reid Kleckner wrote:<br>
</span>
<div class="HOEnZb">
<div class="h5">> It sounds like your DataLayout
may not match clang's for x86_64-linux. What<br>
> does it say about the alignment of i64?<br>
> On Wed, Apr 18, 2018 at 12:05 PM edA-qa
mort-ora-y via llvm-dev <<br>
> <a href="mailto:llvm-dev@lists.llvm.org"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
wrote:<br>
><br>
>> I'm creating a struct of `{i8,i64}` and
`DataLayout::getTypeAllocSize`<br>
>> is returning `12`. `getStructLayout` also
gives an `4` offset for the<br>
>> second element.<br>
>> The native ABI, and clang, for the same
type are producing a size of 16,<br>
>> with an alignment of 8, for the second
element.<br>
>> This is for the system triple
"x86_64-linux-gnu"<br>
>> What could be causing this difference in
alignment and how can I fix it?<br>
><br>
>> I'm verifying the native ABI with:<br>
>> // clang -emit-llvm ll_struct_arg.c -S
-o /dev/tty<br>
>> #include <stddef.h><br>
>> typedef struct vpt_data {<br>
>> _Bool c;<br>
>> long int b;<br>
>> } vpt_data;<br>
>> int main() {<br>
>> vpt_data v;<br>
>> vpt_test(v);<br>
>> auto a = sizeof(v);<br>
>> auto off = offsetof(vpt_data,b);<br>
>> }<br>
><br>
>> 16 is stored to `a` and 8 to `off`.<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>
>> 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>
>> 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>
>> Twitter<br>
>> edaqa<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>
<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>
</div>
</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>