https://github.com/16srivarshitha created https://github.com/llvm/llvm-project/pull/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.* >From cd2f398d5e17e1985453fb24e7153d2f4cb5395d Mon Sep 17 00:00:00 2001 From: 16srivarshitha <[email protected]> Date: Sat, 28 Feb 2026 23:09:19 +0530 Subject: [PATCH 1/4] [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 <[email protected]> Date: Sat, 28 Feb 2026 23:17:19 +0530 Subject: [PATCH 2/4] [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 <[email protected]> Date: Sun, 1 Mar 2026 16:53:04 +0530 Subject: [PATCH 3/4] [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 <[email protected]> Date: Sun, 1 Mar 2026 16:54:23 +0530 Subject: [PATCH 4/4] [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; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
