1 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
2 // Exercise various use cases for local asm "register variables".
5 // CHECK-LABEL: define{{.*}} i32 @foo()
6 // CHECK: [[A:%[a-zA-Z0-9]+]] = alloca i32
8 register int a
asm("rsi")=5;
9 // CHECK: store i32 5, ptr [[A]]
11 asm volatile("; %0 This asm defines rsi" : "=r"(a
));
12 // CHECK: [[Z:%[a-zA-Z0-9]+]] = call i32 asm sideeffect "; $0 This asm defines rsi", "={rsi},~{dirflag},~{fpsr},~{flags}"()
13 // CHECK: store i32 [[Z]], ptr [[A]]
16 // CHECK: store i32 42, ptr [[A]]
18 asm volatile("; %0 This asm uses rsi" : : "r"(a
));
19 // CHECK: [[TMP:%[a-zA-Z0-9]+]] = load i32, ptr [[A]]
20 // CHECK: call void asm sideeffect "; $0 This asm uses rsi", "{rsi},~{dirflag},~{fpsr},~{flags}"(i32 [[TMP]])
23 // CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32, ptr [[A]]
24 // CHECK: ret i32 [[TMP1]]
27 int earlyclobber(void) {
28 // CHECK-LABEL: define{{.*}} i32 @earlyclobber()
29 // CHECK: [[A:%[a-zA-Z0-9]+]] = alloca i32
31 register int a
asm("rsi")=5;
32 // CHECK: store i32 5, ptr [[A]]
34 asm volatile("; %0 This asm defines rsi" : "=&r"(a
));
35 // CHECK: [[Z:%[a-zA-Z0-9]+]] = call i32 asm sideeffect "; $0 This asm defines rsi", "=&{rsi},~{dirflag},~{fpsr},~{flags}"()
36 // CHECK: store i32 [[Z]], ptr [[A]]
39 // CHECK: store i32 42, ptr [[A]]
41 asm volatile("; %0 This asm uses rsi" : : "r"(a
));
42 // CHECK: [[TMP:%[a-zA-Z0-9]+]] = load i32, ptr [[A]]
43 // CHECK: call void asm sideeffect "; $0 This asm uses rsi", "{rsi},~{dirflag},~{fpsr},~{flags}"(i32 [[TMP]])
46 // CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32, ptr [[A]]
47 // CHECK: ret i32 [[TMP1]]