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

            Bug ID: 23345
           Summary: [globalsmodref-aa] Atomics not considered to access
                    memory.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Global Analyses
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

The loop "// Scan the function bodies for explicit loads or stores." in
http://llvm.org/klaus/llvm/blob/master/lib/Analysis/IPA/GlobalsModRef.cpp#L-438
appears to ignore atomic operations (e.g. cmpxchg, atomicrmw).

Patch will be on llvm-commits shortly.

This bug has probably been latent since those instructions were introduced. A
quick blame shows the loop was last touched in 2012.

I found this because the "compare and swap" was being hoisted out of a standard
"compare and swap" loop with -fno-inline:

test case:

opt -S <test2.ll -globalsmodref-aa -licm

test2.ll:

target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"

define i32 @_Z1fPx(i64* %p) {
  br label %1

; <label>:1                                       ; preds = %1, %0
  %2 = call i64 @_ZL16compareAndSwap64Pxxx(i64* %p)
  %3 = icmp eq i64 %2, 0
  br i1 %3, label %1, label %4

; <label>:4                                       ; preds = %1
  ret i32 3
}

define internal i64 @_ZL16compareAndSwap64Pxxx(i64* %ptr) nounwind {
  %1 = cmpxchg i64* %ptr, i64 0, i64 -1 monotonic monotonic
  %2 = extractvalue { i64, i1 } %1, 1
  %3 = extractvalue { i64, i1 } %1, 0
  %. = select i1 %2, i64 0, i64 %3
  ret i64 %.
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to