1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc // Exercise various use cases for local asm "register variables".
3*f4a2713aSLionel Sambuc
foo()4*f4a2713aSLionel Sambuc int foo() {
5*f4a2713aSLionel Sambuc // CHECK: [[A:%[a-zA-Z0-9]+]] = alloca i32
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc register int a asm("rsi")=5;
8*f4a2713aSLionel Sambuc // CHECK: store i32 5, i32* [[A]]
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc asm volatile("; %0 This asm defines rsi" : "=r"(a));
11*f4a2713aSLionel Sambuc // CHECK: [[Z:%[a-zA-Z0-9]+]] = call i32 asm sideeffect "; $0 This asm defines rsi", "={rsi},~{dirflag},~{fpsr},~{flags}"()
12*f4a2713aSLionel Sambuc // CHECK: store i32 [[Z]], i32* [[A]]
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc a = 42;
15*f4a2713aSLionel Sambuc // CHECK: store i32 42, i32* [[A]]
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc asm volatile("; %0 This asm uses rsi" : : "r"(a));
18*f4a2713aSLionel Sambuc // CHECK: [[TMP:%[a-zA-Z0-9]+]] = load i32* [[A]]
19*f4a2713aSLionel Sambuc // CHECK: call void asm sideeffect "; $0 This asm uses rsi", "{rsi},~{dirflag},~{fpsr},~{flags}"(i32 [[TMP]])
20*f4a2713aSLionel Sambuc
21*f4a2713aSLionel Sambuc return a;
22*f4a2713aSLionel Sambuc // CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32* [[A]]
23*f4a2713aSLionel Sambuc // CHECK: ret i32 [[TMP1]]
24*f4a2713aSLionel Sambuc }
25