29 lines
951 B
LLVM
29 lines
951 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
|
|
|
|
@val = internal global i64 0
|
|
@"\01LC" = internal constant [7 x i8] c"0x%lx\0A\00"
|
|
|
|
define i32 @main() nounwind {
|
|
; CHECK-LABEL: main:
|
|
; CHECK: ## %bb.0: ## %entry
|
|
; CHECK-NEXT: pushq %rax
|
|
; CHECK-NEXT: movl $1, %ecx
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
; CHECK-NEXT: lock cmpxchgq %rcx, {{.*}}(%rip)
|
|
; CHECK-NEXT: leaq {{.*}}(%rip), %rdi
|
|
; CHECK-NEXT: movq %rax, %rsi
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
; CHECK-NEXT: callq _printf
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
; CHECK-NEXT: popq %rcx
|
|
; CHECK-NEXT: retq
|
|
entry:
|
|
%t0 = cmpxchg i64* @val, i64 0, i64 1 monotonic monotonic
|
|
%0 = extractvalue { i64, i1 } %t0, 0
|
|
%1 = tail call i32 (i8*, ...) @printf(i8* getelementptr ([7 x i8], [7 x i8]* @"\01LC", i32 0, i64 0), i64 %0) nounwind
|
|
ret i32 0
|
|
}
|
|
|
|
declare i32 @printf(i8*, ...) nounwind
|