<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">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">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">http://mortoray.com/</a><br>
>> Creator of the Leaf language<br>
>> <a href="http://leaflang.org/" rel="noreferrer" target="_blank">http://leaflang.org/</a><br>
>> Streaming algorithms, AI, and design on Twitch<br>
>> <a href="https://www.twitch.tv/mortoray" rel="noreferrer" target="_blank">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">llvm-dev@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">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">http://mortoray.com/</a><br>
<br>
Creator of the Leaf language<br>
<a href="http://leaflang.org/" rel="noreferrer" target="_blank">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">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">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div></div></div>