[llvm-bugs] [Bug 48591] [11 regression] Code segfaults with -O1 -mavx2

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 24 10:00:39 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48591

Roman Lebedev <lebedev.ri at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lebedev.ri at gmail.com
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Roman Lebedev <lebedev.ri at gmail.com> ---
https://godbolt.org/z/dq4xGz

(In reply to Evan Nemerson from comment #0)
> I have some code which has started segfaulting (often, but not reliably)
> when compiled with `clang-11 -O1 -mavx2`.  clang-10 works reliably, as do
> other optimization levels.
> 
> I (well, C-Reduce) have reduced it to the following:
> 
>     typedef long a __attribute__((__vector_size__(32)));
>     a d, e;
>     void b(a *p1) { __builtin_memcpy(p1, &d, sizeof(d)); }
>     int main() {
>       {
>         {

>           int c[sizeof(e) / sizeof(int)];
>           b(({ (a *)c; }));
This is UB.
`c` is only aligned as an `int` (4 bytes, even though it is effectively aligned
by 16 bytes),
yet you cast it to `a`, which is more strictly aligned (32 bytes).

>         }
>       }
>     }
> Here it is on Compiler Explorer: <https://godbolt.org/z/z8d6hK>.  The exit
> code for clang-11 is 139 for me now, but I can't promise it will be for you;
> as I mentioned it doesn't crash every time, and I'm pretty sure Compiler
> Explorer caches results. On my desktop it's crashing on ~52% of executions.
> 
> This happens with a *lot* of the test cases in SIMDe
> (<https://github.com/simd-everywhere/simde>) if anyone wants to try
> reproducing with "real" code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201224/e727d0fe/attachment-0001.html>


More information about the llvm-bugs mailing list