[LLVMbugs] [Bug 8589] New: Wrong atomic intrinsic codegen at -O0

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 11 12:22:54 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8589

           Summary: Wrong atomic intrinsic codegen at -O0
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: baldrick at free.fr
                CC: llvmbugs at cs.uiuc.edu


Running "llc -O1" (or higher -O level) on the attached testcase results in
correct code.  But with "llc -O0", an atomic operation is reordered wrongly:

  call void @GOMP_loop_end_nowait() nounwind
  %13 = getelementptr inbounds i8* %.omp_data_i, i64 8
  %14 = bitcast i8* %13 to i32*
  call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 true)
  %15 = call i32 @llvm.atomic.load.and.i32.p0i32(i32* %14, i32 %12)
  call void @llvm.memory.barrier(i1 true, i1 true, i1 true, i1 true, i1 true)

->

        lock
        cmpxchgl        %ecx, (%rsi)
        movl    %eax, (%rsp)            # 4-byte Spill
        jne     .LBB0_6
# BB#7:                                 # %6
        callq   GOMP_loop_end_nowait
        movabsq $8, %rax
        movq    88(%rsp), %rcx          # 8-byte Reload
        addq    %rcx, %rax
        mfence
        mfence

There are several crazy things here.  First off, the atomic operation has
been moved before the call to GOMP_loop_end_nowait, which is just wrong
since it writes to memory that is manipulated by GOMP_loop_end_nowait.
It has also been moved out from between the memory barriers (leaving the
two lonely "mfence" instructions with the atomic no longer between them!).

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list