[LLVMbugs] [Bug 22273] New: CmpXchg with optimization off inserts lock-releasing spill

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 20 13:33:23 PST 2015


            Bug ID: 22273
           Summary: CmpXchg with optimization off inserts lock-releasing
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: proxytag at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13713
  --> http://llvm.org/bugs/attachment.cgi?id=13713&action=edit
Source code

When compiling the following with -O0

; ModuleID = 'testios64'
target triple = "arm64-apple-ios"

declare void @X(i64)

define linkonce void @Foo() {
  %Target = alloca i64
  %NewValue = alloca i64
  %Comparand = alloca i64
  %0 = load i64* %NewValue
  %1 = load i64* %Comparand
  %2 = cmpxchg i64* %Target, i64 %1, i64 %0 seq_cst seq_cst
  %3 = extractvalue { i64, i1 } %2, 0
  call void @X(i64 %3)
  ret void

The CmpXChg code generated is:

LBB0_1:                                 ; %cmpxchg.start
                                        ; =>This Inner Loop Header: Depth=1
    sub    x8, x29, #8             ; =8
    ldaxr    x8, [x8]
    ldr    x9, [sp, #8]            ; 8-byte Folded Reload
    cmp     x8, x9
    str     x8, [sp]               ; 8-byte Folded Spill <--- LOCK RELEASED
    b.eq    LBB0_2
    b    LBB0_3
LBB0_2:                                 ; %cmpxchg.trystore
                                        ;   in Loop: Header=BB0_1 Depth=1
    sub    x8, x29, #8             ; =8
    ldr    x10, [sp, #16]          ; 8-byte Folded Reload
    stlxr    w9, x10, [x8]
    cmp     w9, #0                 ; =0
    b.eq    LBB0_3
    b    LBB0_1
LBB0_3:                                 ; %cmpxchg.end
    ldr     x0, [sp]               ; 8-byte Folded Reload

The spill instruction (str x8, [sp]) releases the exclusive lock.

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/20150120/19e3bfee/attachment.html>

More information about the llvm-bugs mailing list