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

Hans Wennborg <h...@chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ahmed.bouga...@gmail.com
         Resolution|---                         |FIXED

--- Comment #2 from Hans Wennborg <h...@chromium.org> ---
(In reply to comment #1)
> Hans, this looks like PR31367
> (https://llvm.org/bugs/show_bug.cgi?id=31367#c8). What do you think?

Yes, that's exactly it. The bug was introduced in r265636, i.e. llvm 3.9.

My best idea for working around it would be doing the fetch_add operation in a
noinline function :-/

My fix in r291630, which will be in llvm 4, affects the repro like this:

@@ -19,12 +19,13 @@
 _Z13test_functionv:                     # @_Z13test_functionv
        .cfi_startproc
 # BB#0:                                 # %entry
+       movl    $1, %eax
+       lock            xaddq   %rax, foo(%rip)
        testq   %rax, %rax
        setns   %al
-       lock            incq    foo(%rip)
        movl    $value_a, %ecx
        movl    $value_b, %edx
-       cmovgq  %rcx, %rdx
+       cmovnsq %rcx, %rdx
        cmpl    $100, (%rdx)
        je      .LBB1_3
 # BB#1:
@@ -37,11 +38,12 @@
        movl    $foo+16, %eax
        cmovneq %rcx, %rax
        lock            incq    (%rax)
+       movl    $1, %eax
+       lock            xaddq   %rax, foo(%rip)
        testq   %rax, %rax
        setns   %al
-       lock            incq    foo(%rip)
        movl    $value_b, %esi
-       cmovgq  %rdx, %rsi
+       cmovnsq %rdx, %rsi
        cmpl    $100, (%rsi)
        jne     .LBB1_2
 .LBB1_3:                                # %if.end.thread

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to