2014-08-27 05:10:47 +08:00
|
|
|
// RUN: %clang_cc1 -fms-extensions -emit-llvm -o - %s | FileCheck %s
|
2010-11-30 09:47:38 +08:00
|
|
|
|
2011-07-10 01:41:47 +08:00
|
|
|
// CHECK: %struct.test = type { i32, %struct.nested2, i32 }
|
|
|
|
// CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 }
|
2010-11-30 09:47:38 +08:00
|
|
|
// CHECK: %struct.nested1 = type { i32, i32 }
|
|
|
|
typedef struct nested1 {
|
|
|
|
int a1;
|
|
|
|
int b1;
|
|
|
|
} NESTED1;
|
|
|
|
|
|
|
|
struct nested2 {
|
|
|
|
int a;
|
|
|
|
NESTED1;
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct test {
|
|
|
|
int x;
|
|
|
|
struct nested2;
|
|
|
|
int y;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void foo()
|
|
|
|
{
|
|
|
|
// CHECK: %var = alloca %struct.test, align 4
|
|
|
|
struct test var;
|
|
|
|
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var.a;
|
|
|
|
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 2
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var.b;
|
|
|
|
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested1, %struct.nested1* %{{.*}}, i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var.a1;
|
|
|
|
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}var, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested1, %struct.nested1* %{{.*}}, i32 0, i32 1
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var.b1;
|
|
|
|
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var.x;
|
|
|
|
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 2
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void foo2(struct test* var)
|
|
|
|
{
|
|
|
|
// CHECK: alloca %struct.test*, align
|
|
|
|
// CHECK-NEXT: store %struct.test* %var, %struct.test** %{{.*}}, align
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var->a;
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 2
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var->b;
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested1, %struct.nested1* %{{.*}}, i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var->a1;
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 1
|
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.nested1, %struct.nested1* %{{.*}}, i32 0, i32 1
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var->b1;
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var->x;
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 2
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
|
2010-11-30 09:47:38 +08:00
|
|
|
var->y;
|
|
|
|
}
|