[ELF] Reorder SectionBase/InputSectionBase members
[llvm-project.git] / clang / test / CodeGen / asm-reg-var-local.c
blob4e366cabb63940670a8ca53227096dfec1bc5df0
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".
4 int foo(void) {
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]]
15 a = 42;
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]])
22 return a;
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]]
38 a = 42;
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]])
45 return a;
46 // CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32, ptr [[A]]
47 // CHECK: ret i32 [[TMP1]]