<div dir="ltr">> <span style="font-size:12.8px">Presumably CoreCLR builds with -Werror, <br></span>Right. <div><br></div><div>> <span style="font-size:12.8px">But there's really no reason to use -O4 in the first place </span><span style="font-size:12.8px">since it's identical to -O3.<br>Actually, I thought that -O4</span><span style="font-size:12.8px"> </span><span style="font-size:12.8px">means "link-time optimization" based on -O3 </span><span style="font-size:12.8px"> (e.g., -</span><span style="font-size:12.8px">O3 + -flto ). </span><span style="font-size:12.8px"><br><br><br>> </span><span style="font-size:12.8px">When I grepped CoreCLR I saw rather</span><br style="font-size:12.8px"><span style="font-size:12.8px">> more uses of UNALIGNED than the two functions you've patched.</span><br><span style="font-size:12.8px">Yes, So, It seems that we have to add an exception handling  to proceed arm-specific condition in case of -O3(clang) as following:</span><br><br><div style=""><span style="font-size:12.8px">---</span><br></div><div style=""><span style="font-size:12.8px"> src/jit/compiler.hpp | 8 ++++----</span></div><div style=""><span style="font-size:12.8px"> src/pal/inc/pal.h    | 6 ++++++</span></div><div style=""><span style="font-size:12.8px"> 2 files changed, 10 insertions(+), 4 deletions(-)</span></div><div style=""><span style="font-size:12.8px"><br></span></div><div style=""><span style="font-size:12.8px">diff --git a/src/jit/compiler.hpp b/src/jit/compiler.hpp</span></div><div style=""><span style="font-size:12.8px">index 7a16b7c..8cee77e 100644</span></div><div style=""><span style="font-size:12.8px">--- a/src/jit/compiler.hpp</span></div><div style=""><span style="font-size:12.8px">+++ b/src/jit/compiler.hpp</span></div><div style=""><span style="font-size:12.8px">@@ -757,16 +757,16 @@ inline</span></div><div style=""><span style="font-size:12.8px">   signed __int16    getI2LittleEndian(const BYTE * ptr)</span></div><div style=""><span style="font-size:12.8px"> { return * (UNALIGNED signed __int16 *)ptr; }</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px">-typedef signed __int32 __attribute__((aligned(1))) __unaligned_arm_int32;</span></div><div style=""><span style="font-size:12.8px">-typedef signed __int64 __attribute__((aligned(1))) __unaligned_arm_int64;</span></div><div style=""><span style="font-size:12.8px">+typedef signed __int32 UNALIGNED_ARM __unaligned_int32;</span></div><div style=""><span style="font-size:12.8px">+typedef signed __int64 UNALIGNED_ARM __unaligned_int64;</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px"> inline</span></div><div style=""><span style="font-size:12.8px">   signed __int32    getI4LittleEndian(const BYTE * ptr)</span></div><div style=""><span style="font-size:12.8px">-{ return *(__unaligned_arm_int32 *)ptr; }</span></div><div style=""><span style="font-size:12.8px">+{ return *(__unaligned_int32 *)ptr; }</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px"> inline</span></div><div style=""><span style="font-size:12.8px">   signed __int64    getI8LittleEndian(const BYTE * ptr)</span></div><div style=""><span style="font-size:12.8px">-{ return *(__unaligned_arm_int64 *)ptr; }</span></div><div style=""><span style="font-size:12.8px">+{ return *(__unaligned_int64 *)ptr; }</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px"> inline</span></div><div style=""><span style="font-size:12.8px"> float               getR4LittleEndian(const BYTE * ptr)</span></div><div style=""><span style="font-size:12.8px">diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h</span></div><div style=""><span style="font-size:12.8px">index 5b44661..b95d74c 100644</span></div><div style=""><span style="font-size:12.8px">--- a/src/pal/inc/pal.h</span></div><div style=""><span style="font-size:12.8px">+++ b/src/pal/inc/pal.h</span></div><div style=""><span style="font-size:12.8px">@@ -201,7 +201,13 @@ extern "C" {</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px"> #else // _MSC_VER</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px">+#if defined (_M_ARM) && !defined (DEBUG)</span></div><div style=""><span style="font-size:12.8px"> #define UNALIGNED</span></div><div style=""><span style="font-size:12.8px">+#define UNALIGNED_ARM     __attribute__((aligned(1))) //for -O2 and -O3</span></div><div style=""><span style="font-size:12.8px">+#else</span></div><div style=""><span style="font-size:12.8px">+#define UNALIGNED</span></div><div style=""><span style="font-size:12.8px">+#define UNALIGNED_ARM  //for -O0</span></div><div style=""><span style="font-size:12.8px">+#endif</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px"> #endif // _MSC_VER</span></div><div style=""><span style="font-size:12.8px"> </span></div><div style=""><span style="font-size:12.8px">-- </span></div><div style=""><span style="font-size:12.8px">1.9.1</span></div><br><span style="font-size:12.8px"> </span><br><span class="im" style="font-size:12.8px">>> Do I have to compare the generated instructions to find appropriate patch?<br>> </span><span style="font-size:12.8px">I'd expect them to be equivalent after optimization</span><span style="font-size:12.8px"><br>Do you mean that we get the similar instructions between "memcpy()"  library call <br>and " __attribute__(aligned(1)) keyword".<br><br>Thanks. </span><div><span style="font-size:12.8px"><br><br>BRs,<br>Geunsik Lim. </span><div><span style="font-size:12.8px"><br><br></span></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 15, 2016 at 12:00 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 14 July 2016 at 19:47, Geunsik Lim <<a href="mailto:leemgs@gmail.com">leemgs@gmail.com</a>> wrote:<br>
>> It won't give you an error (just a warning), but no-one I know thinks<br>
>>  doing anything special with it is a good idea. It's accepted purely<br>
>> for compatibility I think.<br>
><br>
> When I used -O3, I have got the below messages while building CoreCLR.<br>
<br>
</span>Presumably CoreCLR builds with -Werror, which turns any warning into<br>
an error. But there's really no reason to use -O4 in the first place<br>
since it's identical to -O3.<br>
<span class=""><br>
> I am not sure which solution is better between the below two patches.<br>
> Could you tell me comment to get the best way?<br>
<br>
</span>A lot of it comes down to personal preference. Both approaches are<br>
functional but you'd have to ask the CoreCLR developers which they<br>
prefer.<br>
<br>
One thing to be wary of is that those patches look like very partial<br>
fixes. They may get rid of the current segfault, but leave the<br>
underlying problem open in other places (just waiting for some minor<br>
change in Clang to trigger it). When I grepped CoreCLR I saw rather<br>
more uses of UNALIGNED than the two functions you've patched.<br>
<span class=""><br>
> Do I have to compare the generated instructions to find appropriate patch?<br>
<br>
</span>I'd expect them to be equivalent after optimization.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><a href="http://leemgs.fedorapeople.org" style="font-family:Tahoma" target="_blank">http://leemgs.fedorapeople.org</a><span style="font-family:Tahoma"> </span></div><div>Don't try to avoid pain if you fail.<br>If you decided to face the challenges in life, <br>you can gain a lot by giving your best.<br>Cheolsang Jeong's Book & life<br>--<br></div></div></div>
</div>