Skip to content

Commit 5e85698

Browse files
committed
Add test cases
1 parent 2223527 commit 5e85698

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

clang/test/CIR/CodeGen/struct.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
5+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
6+
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
7+
8+
struct IncompleteS;
9+
IncompleteS *p;
10+
11+
// CIR: cir.global external @p = #cir.ptr<null> : !cir.ptr<!cir.struct<struct "IncompleteS" incomplete>>
12+
// LLVM: @p = dso_local global ptr null
13+
// OGCG: @p = global ptr null, align 8
14+
15+
void f(void) {
16+
IncompleteS *p;
17+
}
18+
19+
// CIR: cir.func @f()
20+
// CIR-NEXT: cir.alloca !cir.ptr<!cir.struct<struct "IncompleteS" incomplete>>,
21+
// CIR-SAME: !cir.ptr<!cir.ptr<!cir.struct<struct "IncompleteS" incomplete>>>, ["p"]
22+
// CIR-NEXT: cir.return
23+
24+
// LLVM: define void @f()
25+
// LLVM-NEXT: %[[P:.*]] = alloca ptr, i64 1, align 8
26+
// LLVM-NEXT: ret void
27+
28+
// OGCG: define{{.*}} void @_Z1fv()
29+
// OGCG-NEXT: entry:
30+
// OGCG-NEXT: %[[P:.*]] = alloca ptr, align 8
31+
// OGCG-NEXT: ret void

clang/test/CIR/CodeGen/union.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
5+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
6+
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
7+
8+
union IncompleteU *p;
9+
10+
// CIR: cir.global external @p = #cir.ptr<null> : !cir.ptr<!cir.struct<union "IncompleteU" incomplete>>
11+
// LLVM: @p = dso_local global ptr null
12+
// OGCG: @p = global ptr null, align 8
13+
14+
void f(void) {
15+
union IncompleteU *p;
16+
}
17+
18+
// CIR: cir.func @f()
19+
// CIR-NEXT: cir.alloca !cir.ptr<!cir.struct<union "IncompleteU" incomplete>>,
20+
// CIR-SAME: !cir.ptr<!cir.ptr<!cir.struct<union "IncompleteU" incomplete>>>, ["p"]
21+
// CIR-NEXT: cir.return
22+
23+
// LLVM: define void @f()
24+
// LLVM-NEXT: %[[P:.*]] = alloca ptr, i64 1, align 8
25+
// LLVM-NEXT: ret void
26+
27+
// OGCG: define{{.*}} void @f()
28+
// OGCG-NEXT: entry:
29+
// OGCG-NEXT: %[[P:.*]] = alloca ptr, align 8
30+
// OGCG-NEXT: ret void

0 commit comments

Comments
 (0)