<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body dir="auto">
-fnew-alignment=8 makes the crash go away. Can you point me to the documentation for this option? I couldn’t find it.<br>
<br>
<div id="AppleMailSignature">/ Riyaz</div>
<div><br>
On Oct 2, 2017, at 3:44 PM, Craig Topper <<a href="mailto:craig.topper@gmail.com">craig.topper@gmail.com</a>> wrote:<br>
<br>
</div>
<div>
<div dir="ltr">Does the crash happen if you compile with -fnew-alignment=8? That's supposed to change what clang assumes the alignment of memory allocated with new will be.</div>
<div class="gmail_extra"><br clear="all">
<div>
<div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div>
</div>
<br>
<div class="gmail_quote">On Mon, Oct 2, 2017 at 3:11 PM, Riyaz Puthiyapurayil 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">
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_-4238045200672268176WordSection1">
<p class="MsoNormal">I have some programs crashing when I upgraded from clang 3.9.1 to clang 4.0.1.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Debugging this I found the reason for the crash. This is happening in the following assembly fragment for a piece of code allocating a class object (size: 24 bytes) using operator new and then initializing it:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-family:Consolas">   0x00002aaaafc145f3 <+35>:    callq  0x2aaaafdf5f90 <operator new(unsigned long)><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">   0x00002aaaafc145f8 <+40>:    mov    %rax,%r13<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">   0x00002aaaafc145fb <+43>:    xorps  %xmm0,%xmm0<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">=> 0x00002aaaafc145fe <+46>:   
<span style="color:red">movaps %xmm0,0x0(%r13)</span><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The value in %r13 (from the return value of operator new) is not appropriately aligned causing the crash. The memory allocation is done by a custom memory allocator that is returning 8-byte aligned blocks. The memory allocator has not changed
 between the two versions of the program (the one using clang 3.9.1 versus the one using clang 4.0.1). The version of libstdc++ is also the same. The command line options to clang are unchanged (-msse2 is specified in both cases). But I found that clang 3.9.1
 is not generating SSE instructions but clang 4.0.1 is generating them in the above case.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The fix in our code is to make an API call to configure the custom allocator to always return appropriately aligned memory. But I would like to know if there is a known change in LLVM or clang to assume that malloc will return > 8 byte
 aligned memory based on the allocation size  or if this has always been the case. I want to know if my program compiled with 3.9.1 also has a problem that was just not exposed in testing.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks in advance.<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></p>
<span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">/Riyaz<u></u><u></u></p>
</font></span></div>
</div>
<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="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=DwMFaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=mMZWMrEZcvPMLSsEQSah9FOTwza1UudSDkAneN47U9lD3qu6gt3kpnIb4MWV77cM&m=q9SGsai0JEZwsIwupiWLBnPcZSxAkYIMkrR1rNw2RC4&s=1BMveWM9s7snji5Imqqfm8DIHH1A6VqWju-HyakRIg0&e=" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</body>
</html>