[clang] a6fa21c - [CIR] Upstream basic CodeGen tests from incubator (#183998)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 2 16:46:31 PST 2026
Author: Srivarshitha M
Date: 2026-03-02T16:46:27-08:00
New Revision: a6fa21c5aabb9e7d47c221aa8403d96cb154d549
URL: https://github.com/llvm/llvm-project/commit/a6fa21c5aabb9e7d47c221aa8403d96cb154d549
DIFF: https://github.com/llvm/llvm-project/commit/a6fa21c5aabb9e7d47c221aa8403d96cb154d549.diff
LOG: [CIR] Upstream basic CodeGen tests from incubator (#183998)
This PR upstreams `expressions.cpp` and `c89-implicit-int.c` from the
ClangIR incubator to the mainline.
Following the incremental approach discussed in #156747 and the feedback
from the closed PR #157333, I have:
1. Copied the files directly from the incubator to preserve history.
2. Updated the `RUN` lines to use the `--check-prefix=CIR` flag.
3. Converted `CHECK:` lines to `CIR:`.
4. Standardized variable captures using the `%[[VAR:.*]]` regex syntax
(in `expressions.cpp`).
Verified locally with `llvm-lit`. This is a partial fix for #156747.
*Note: As suggested in previous reviews, I am focusing only on the `CIR`
checks for now to keep the upstreaming incremental. OGCG/LLVM
verification can be added in a follow-up PR once the base tests land.*
Added:
clang/test/CIR/CodeGen/c89-implicit-int.c
clang/test/CIR/CodeGen/expressions.cpp
Modified:
Removed:
################################################################################
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..f7e6153cbfbf2
--- /dev/null
+++ b/clang/test/CIR/CodeGen/c89-implicit-int.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c89 -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
+
+// Implicit int return type.
+test = 0;
+func (void) {
+ 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
new file mode 100644
index 0000000000000..50bffbfb68739
--- /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 --check-prefix=CIR
+
+void test(int a) {
+ // Should generate LValue parenthesis expression.
+ (a) = 1;
+}
+
+// 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