[clang] [CIR] Upstream basic CodeGen tests from incubator (PR #183998)
Srivarshitha M via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 1 10:59:33 PST 2026
https://github.com/16srivarshitha updated https://github.com/llvm/llvm-project/pull/183998
>From cd2f398d5e17e1985453fb24e7153d2f4cb5395d Mon Sep 17 00:00:00 2001
From: 16srivarshitha <mvarshitha17874 at gmail.com>
Date: Sat, 28 Feb 2026 23:09:19 +0530
Subject: [PATCH 1/5] [CIR] Copy expressions.cpp from incubator
---
clang/test/CIR/CodeGen/expressions.cpp | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 clang/test/CIR/CodeGen/expressions.cpp
diff --git a/clang/test/CIR/CodeGen/expressions.cpp b/clang/test/CIR/CodeGen/expressions.cpp
new file mode 100644
index 0000000000000..eafdb2289e201
--- /dev/null
+++ b/clang/test/CIR/CodeGen/expressions.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+void test(int a) {
+// CHECK: cir.func {{.*}} @{{.+}}test
+
+ // Should generate LValue parenthesis expression.
+ (a) = 1;
+ // CHECK: %[[#C:]] = cir.const #cir.int<1> : !s32i
+ // CHECK: cir.store{{.*}} %[[#C]], %{{.+}} : !s32i, !cir.ptr<!s32i>
+}
>From fd0ceee9c13e4b1c943b510777342ed78f6cbf8f Mon Sep 17 00:00:00 2001
From: 16srivarshitha <mvarshitha17874 at gmail.com>
Date: Sat, 28 Feb 2026 23:17:19 +0530
Subject: [PATCH 2/5] [CIR] Update expressions.cpp to use CIR prefix
---
clang/test/CIR/CodeGen/expressions.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/test/CIR/CodeGen/expressions.cpp b/clang/test/CIR/CodeGen/expressions.cpp
index eafdb2289e201..cbd54e2fd4655 100644
--- a/clang/test/CIR/CodeGen/expressions.cpp
+++ b/clang/test/CIR/CodeGen/expressions.cpp
@@ -1,11 +1,11 @@
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
void test(int a) {
-// CHECK: cir.func {{.*}} @{{.+}}test
+// CIR: cir.func {{.*}} @{{.+}}test
// Should generate LValue parenthesis expression.
(a) = 1;
- // CHECK: %[[#C:]] = cir.const #cir.int<1> : !s32i
- // CHECK: cir.store{{.*}} %[[#C]], %{{.+}} : !s32i, !cir.ptr<!s32i>
+ // CIR: %[[CONST:.*]] = cir.const #cir.int<1> : !s32i
+ // CIR: cir.store{{.*}} %[[CONST]], %{{.+}} : !s32i, !cir.ptr<!s32i>
}
>From b95ef03cb6d6e4c0d5f1baeca6eafa293ab6b76b Mon Sep 17 00:00:00 2001
From: 16srivarshitha <mvarshitha17874 at gmail.com>
Date: Sun, 1 Mar 2026 16:53:04 +0530
Subject: [PATCH 3/5] [CIR] Copy c89-implicit-int.c from incubator
---
clang/test/CIR/CodeGen/c89-implicit-int.c | 10 ++++++++++
1 file changed, 10 insertions(+)
create mode 100644 clang/test/CIR/CodeGen/c89-implicit-int.c
diff --git a/clang/test/CIR/CodeGen/c89-implicit-int.c b/clang/test/CIR/CodeGen/c89-implicit-int.c
new file mode 100644
index 0000000000000..9882d2cf4c05e
--- /dev/null
+++ b/clang/test/CIR/CodeGen/c89-implicit-int.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c89 -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+// Implicit int return type.
+test = 0;
+// CHECK: cir.global external @test = #cir.int<0> : !s32i
+func (void) {
+// CHECK: cir.func {{.*}} @func() -> !s32i
+ return 0;
+}
>From 621b590471125a2f51e990ecfbec9df1781b410f Mon Sep 17 00:00:00 2001
From: 16srivarshitha <mvarshitha17874 at gmail.com>
Date: Sun, 1 Mar 2026 16:54:23 +0530
Subject: [PATCH 4/5] [CIR] Update c89-implicit-int.c to use CIR prefix
---
clang/test/CIR/CodeGen/c89-implicit-int.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/test/CIR/CodeGen/c89-implicit-int.c b/clang/test/CIR/CodeGen/c89-implicit-int.c
index 9882d2cf4c05e..f3a98efcc480f 100644
--- a/clang/test/CIR/CodeGen/c89-implicit-int.c
+++ b/clang/test/CIR/CodeGen/c89-implicit-int.c
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c89 -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
// Implicit int return type.
test = 0;
-// CHECK: cir.global external @test = #cir.int<0> : !s32i
+// CIR: cir.global external @test = #cir.int<0> : !s32i
func (void) {
-// CHECK: cir.func {{.*}} @func() -> !s32i
+// CIR: cir.func {{.*}} @func() -> !s32i
return 0;
}
>From 0845b4543025d928a563a0f116837f655884036a Mon Sep 17 00:00:00 2001
From: 16srivarshitha <mvarshitha17874 at gmail.com>
Date: Mon, 2 Mar 2026 00:26:07 +0530
Subject: [PATCH 5/5] [CIR] Address review feedback: move FileCheck lines to
bottom
---
clang/test/CIR/CodeGen/c89-implicit-int.c | 5 +++--
clang/test/CIR/CodeGen/expressions.cpp | 8 ++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/clang/test/CIR/CodeGen/c89-implicit-int.c b/clang/test/CIR/CodeGen/c89-implicit-int.c
index f3a98efcc480f..f7e6153cbfbf2 100644
--- a/clang/test/CIR/CodeGen/c89-implicit-int.c
+++ b/clang/test/CIR/CodeGen/c89-implicit-int.c
@@ -3,8 +3,9 @@
// Implicit int return type.
test = 0;
-// CIR: cir.global external @test = #cir.int<0> : !s32i
func (void) {
-// CIR: cir.func {{.*}} @func() -> !s32i
return 0;
}
+
+// CIR: cir.global external @test = #cir.int<0> : !s32i
+// CIR: cir.func {{.*}} @func() -> !s32i
diff --git a/clang/test/CIR/CodeGen/expressions.cpp b/clang/test/CIR/CodeGen/expressions.cpp
index cbd54e2fd4655..50bffbfb68739 100644
--- a/clang/test/CIR/CodeGen/expressions.cpp
+++ b/clang/test/CIR/CodeGen/expressions.cpp
@@ -2,10 +2,10 @@
// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
void test(int a) {
-// CIR: cir.func {{.*}} @{{.+}}test
-
// Should generate LValue parenthesis expression.
(a) = 1;
- // CIR: %[[CONST:.*]] = cir.const #cir.int<1> : !s32i
- // CIR: cir.store{{.*}} %[[CONST]], %{{.+}} : !s32i, !cir.ptr<!s32i>
}
+
+// CIR: cir.func {{.*}} @{{.+}}test
+// CIR: %[[CONST:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store{{.*}} %[[CONST]], %{{.+}} : !s32i, !cir.ptr<!s32i>
More information about the cfe-commits
mailing list