<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">The <a class="el"
href="http://llvm.org/doxygen/classllvm_1_1DataLayout.html#a43556646ad677cfdcfde2b031fa59173">getABITypeAlignment</a>
function is returning only 4 for an i64, which would explain the
discrepency.<br>
<br>
I double-checked my triple again and ensured it's the same one as
clang. That's apparently not enough. What else do I need to adjust
to get the platform default ABI?<br>
<br>
<br>
On 18/04/18 21:37, Reid Kleckner wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CACs=tyKt-Bp86ay-XZrpLiW-EtdUCLa+u5ee540OVTo++x75Ew@mail.gmail.com">
<pre wrap="">It sounds like your DataLayout may not match clang's for x86_64-linux. What
does it say about the alignment of i64?
On Wed, Apr 18, 2018 at 12:05 PM edA-qa mort-ora-y via llvm-dev <
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I'm creating a struct of `{i8,i64}` and `DataLayout::getTypeAllocSize`
is returning `12`. `getStructLayout` also gives an `4` offset for the
second element.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">The native ABI, and clang, for the same type are producing a size of 16,
with an alignment of 8, for the second element.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">This is for the system triple "x86_64-linux-gnu"
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">What could be causing this difference in alignment and how can I fix it?
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">I'm verifying the native ABI with:
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap=""> // clang -emit-llvm ll_struct_arg.c -S -o /dev/tty
#include <stddef.h>
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap=""> typedef struct vpt_data {
_Bool c;
long int b;
} vpt_data;
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap=""> int main() {
vpt_data v;
vpt_test(v);
auto a = sizeof(v);
auto off = offsetof(vpt_data,b);
}
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">16 is stored to `a` and 8 to `off`.
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">--
edA-qa mort-ora-y
<a class="moz-txt-link-freetext" href="http://mortoray.com/">http://mortoray.com/</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Creator of the Leaf language
<a class="moz-txt-link-freetext" href="http://leaflang.org/">http://leaflang.org/</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">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>
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Twitter
edaqa
</pre>
</blockquote>
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
</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>