<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 28, 2015 at 11:35 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.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 Thu, May 28, 2015 at 2:28 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
> On Thu, May 28, 2015 at 11:09 AM, Duncan P. N. Exon Smith<br>
> <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br>
>><br>
>> Author: dexonsmith<br>
>> Date: Thu May 28 13:09:13 2015<br>
>> New Revision: 238447<br>
>><br>
>> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D238447-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PrPt3YwViLgtKUQ5sbEtEFXAypVCXpPTfPD1zzk4Nqw&s=BqV3ajCGHRudIAhyzMlfathQY2HGGQSFtNHoJDJypbU&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=238447&view=rev</a><br>
>> Log:<br>
>> AsmPrinter: Suppress warnings on GCC from r238362, NFC<br>
>><br>
>> GCC seems to have some overzealous warnings about strict aliasing.<br>
><br>
><br>
> If the warning is wrong, can we just disable it rather than contorting the<br>
> code to suppress it? (especially with the risk that warnings like this in<br>
> GCC tend to be powered by their optimizer & thus might see through this &<br>
> start warning again)<br>
<br>
</span>There were questions as to whether the warning was or was not a false<br>
positive which should be answered before turning off the warning over<br>
it.</blockquote><div><br>According to C++ I believe the warning is correct, but I don't believe there's any compliant way to do this. The correct thing you can do is use placement new on the char buffer, then always use the resulting pointer - but that requires extra storage for a pointer that's bit identical to the a pointer to the char array and we're using this to save the space.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> That being said, I don't see a whole lot of strict aliasing<br>
warnings happening in general. If GCC's optimizer changes and starts<br>
warning on this again, we should probably take more time to understand<br>
why.<br></blockquote><div><br>It looks like practically all uses (in Optional, DenseMap, SmallVector, etc) of AlignedStorage, etc, are aliasing violations and would trigger this warning if/when it's a bit more aggressive, etc.<br><br>I don't think there's much for it but to accept that we're not going to conform to this part of the C++ standard any time soon.<br><br>- David<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
>><br>
>> Rafael reports that this patch suppresses them on GCC 4.9, and I'm<br>
>> hoping this will work for GCC 4.7 as well. I'll watch [1] and iterate<br>
>> if necessary.<br>
>><br>
>> [1]: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__bb.pgr.jp_builders_clang-2D3stage-2Dx86-5F64-2Dlinux_builds_8597&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PrPt3YwViLgtKUQ5sbEtEFXAypVCXpPTfPD1zzk4Nqw&s=1gYi0omPtcEeO1F666LuuPQ2ljBNSdnBLmtTh7U-t4s&e=" target="_blank">http://bb.pgr.jp/builders/clang-3stage-x86_64-linux/builds/8597</a><br>
>><br>
>> Modified:<br>
>> llvm/trunk/include/llvm/CodeGen/DIE.h<br>
>><br>
>> Modified: llvm/trunk/include/llvm/CodeGen/DIE.h<br>
>> URL:<br>
>> <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_CodeGen_DIE.h-3Frev-3D238447-26r1-3D238446-26r2-3D238447-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=PrPt3YwViLgtKUQ5sbEtEFXAypVCXpPTfPD1zzk4Nqw&s=0A8jgKLyh1PB1XqC6IFM7-27TMAlJRxjRzfYbe4ShaA&e=" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=238447&r1=238446&r2=238447&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- llvm/trunk/include/llvm/CodeGen/DIE.h (original)<br>
>> +++ llvm/trunk/include/llvm/CodeGen/DIE.h Thu May 28 13:09:13 2015<br>
>> @@ -340,11 +340,11 @@ private:<br>
>> new (reinterpret_cast<void *>(Val.buffer)) T(V);<br>
>> }<br>
>><br>
>> - template <class T> T &get() { return *reinterpret_cast<T<br>
>> *>(Val.buffer); }<br>
>> - template <class T> const T &get() const {<br>
>> - return *reinterpret_cast<const T *>(Val.buffer);<br>
>> + template <class T> T *get() { return reinterpret_cast<T *>(Val.buffer);<br>
>> }<br>
>> + template <class T> const T *get() const {<br>
>> + return reinterpret_cast<const T *>(Val.buffer);<br>
>> }<br>
>> - template <class T> void destruct() { get<T>().~T(); }<br>
>> + template <class T> void destruct() { get<T>()->~T(); }<br>
>><br>
>> /// Destroy the underlying value.<br>
>> ///<br>
>> @@ -378,11 +378,11 @@ private:<br>
>> return;<br>
>> #define HANDLE_DIEVALUE_SMALL(T)<br>
>> \<br>
>> case is##T:<br>
>> \<br>
>> - construct<DIE##T>(X.get<DIE##T>());<br>
>> \<br>
>> + construct<DIE##T>(*X.get<DIE##T>());<br>
>> \<br>
>> return;<br>
>> #define HANDLE_DIEVALUE_LARGE(T)<br>
>> \<br>
>> case is##T:<br>
>> \<br>
>> - construct<const DIE##T *>(X.get<const DIE##T *>());<br>
>> \<br>
>> + construct<const DIE##T *>(*X.get<const DIE##T *>());<br>
>> \<br>
>> return;<br>
>> #include "llvm/CodeGen/DIEValue.def"<br>
>> }<br>
>> @@ -425,12 +425,12 @@ public:<br>
>> #define HANDLE_DIEVALUE_SMALL(T)<br>
>> \<br>
>> const DIE##T &getDIE##T() const {<br>
>> \<br>
>> assert(getType() == is##T && "Expected " #T);<br>
>> \<br>
>> - return get<DIE##T>();<br>
>> \<br>
>> + return *get<DIE##T>();<br>
>> \<br>
>> }<br>
>> #define HANDLE_DIEVALUE_LARGE(T)<br>
>> \<br>
>> const DIE##T &getDIE##T() const {<br>
>> \<br>
>> assert(getType() == is##T && "Expected " #T);<br>
>> \<br>
>> - return *get<const DIE##T *>();<br>
>> \<br>
>> + return **get<const DIE##T *>();<br>
>> \<br>
>> }<br>
>> #include "llvm/CodeGen/DIEValue.def"<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</div></div></blockquote></div><br></div></div>