llvm-project/clang/test/CodeGen/ms-anonymous-struct.c
Nikita Popov 532dc62b90 [OpaquePtrs][Clang] Add -no-opaque-pointers to tests (NFC)
This adds -no-opaque-pointers to clang tests whose output will
change when opaque pointers are enabled by default. This is
intended to be part of the migration approach described in
https://discourse.llvm.org/t/enabling-opaque-pointers-by-default/61322/9.

The patch has been produced by replacing %clang_cc1 with
%clang_cc1 -no-opaque-pointers for tests that fail with opaque
pointers enabled. Worth noting that this doesn't cover all tests,
there's a remaining ~40 tests not using %clang_cc1 that will need
a followup change.

Differential Revision: https://reviews.llvm.org/D123115
2022-04-07 12:09:47 +02:00

100 lines
3.9 KiB
C

// RUN: %clang_cc1 -no-opaque-pointers -fms-extensions -emit-llvm -o - %s | FileCheck %s
// CHECK: %struct.test = type { i32, %struct.nested2, i32 }
// CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 }
// 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(void)
{
// CHECK: %var = alloca %struct.test, align 4
struct test var;
// CHECK: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 1
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 0
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var.a;
// 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
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var.b;
// 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
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var.a1;
// 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
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var.b1;
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 0
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var.x;
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %var, i32 0, i32 2
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var.y;
}
void foo2(struct test* var)
{
// CHECK: alloca %struct.test*, align
// CHECK-NEXT: store %struct.test* %var, %struct.test** %{{.*}}, align
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 1
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 0
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var->a;
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 1
// CHECK-NEXT: getelementptr inbounds %struct.nested2, %struct.nested2* %{{.*}}, i32 0, i32 2
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var->b;
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
// 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
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var->a1;
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
// 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
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var->b1;
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 0
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var->x;
// CHECK-NEXT: load %struct.test*, %struct.test** %{{.*}}, align
// CHECK-NEXT: getelementptr inbounds %struct.test, %struct.test* %{{.*}}, i32 0, i32 2
// CHECK-NEXT: load i32, i32* %{{.*}}, align 4
var->y;
}