[clang] [CIR] Upstream a batch of passing tests from CIR-Incubator (PR #157333)
Burhan Söğüt via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 12 06:38:19 PDT 2025
https://github.com/bursot updated https://github.com/llvm/llvm-project/pull/157333
>From b51c2c06909a402632fe75709997716cea990fc0 Mon Sep 17 00:00:00 2001
From: Burhan <segabur at hotmail.com>
Date: Sun, 7 Sep 2025 11:52:47 +0300
Subject: [PATCH 01/57] [CIR] Upstream a batch of passing tests from
CIR-Incubator
---
clang/test/CIR/CodeGen/OpenMP/taskwait.cpp | 9 +
clang/test/CIR/CodeGen/StringExample.cpp | 34 +++
clang/test/CIR/CodeGen/binassign.cpp | 75 +++++
clang/test/CIR/CodeGen/bswap.cpp | 30 ++
clang/test/CIR/CodeGen/c89-implicit-int.c | 10 +
clang/test/CIR/CodeGen/comma.cpp | 30 ++
clang/test/CIR/CodeGen/complex-cast.c | 264 ++++++++++++++++++
.../test/CIR/CodeGen/compound-literal-empty.c | 18 ++
clang/test/CIR/CodeGen/expressions.cpp | 11 +
clang/test/CIR/CodeGen/func_dsolocal_pie.c | 34 +++
clang/test/CIR/CodeGen/gnu89.c | 5 +
clang/test/CIR/CodeGen/if-constexpr.cpp | 92 ++++++
clang/test/CIR/CodeGen/implicit-return.cpp | 26 ++
clang/test/CIR/CodeGen/inc-bool.cpp | 14 +
clang/test/CIR/CodeGen/inc-dec.cpp | 55 ++++
clang/test/CIR/CodeGen/lalg.c | 20 ++
clang/test/CIR/CodeGen/literals.c | 9 +
clang/test/CIR/CodeGen/literals.cpp | 8 +
clang/test/CIR/CodeGen/loop-scope.cpp | 32 +++
clang/test/CIR/CodeGen/lvalue-refs.cpp | 19 ++
clang/test/CIR/CodeGen/ms-intrinsics-other.c | 55 ++++
clang/test/CIR/CodeGen/no-pie.c | 11 +
clang/test/CIR/CodeGen/no-proto-fun-ptr.c | 27 ++
clang/test/CIR/CodeGen/no-proto-is-void.cpp | 13 +
.../CIR/CodeGen/null-arithmatic-expression.c | 12 +
clang/test/CIR/CodeGen/operators.cpp | 14 +
clang/test/CIR/CodeGen/optimization-attr.cpp | 32 +++
clang/test/CIR/CodeGen/pointer.cpp | 6 +
clang/test/CIR/CodeGen/return.cpp | 33 +++
clang/test/CIR/CodeGen/shift.cpp | 8 +
clang/test/CIR/CodeGen/spelling-locations.cpp | 100 +++++++
clang/test/CIR/CodeGen/std-array.cpp | 13 +
clang/test/CIR/CodeGen/stmt-expr.c | 42 +++
clang/test/CIR/CodeGen/store.c | 29 ++
.../switch-unreachable-after-break.cpp | 49 ++++
clang/test/CIR/CodeGen/trap.cpp | 28 ++
clang/test/CIR/CodeGen/types-IEEE-quad.c | 32 +++
clang/test/CIR/CodeGen/types-nullptr.cpp | 9 +
clang/test/CIR/CodeGen/types.c | 46 +++
clang/test/CIR/CodeGen/unary.c | 44 +++
clang/test/CIR/CodeGen/unreachable.cpp | 28 ++
clang/test/CIR/Lowering/bitfieils.c | 32 +++
clang/test/CIR/Lowering/global-ptr.c | 55 ++++
clang/test/CIR/Lowering/nested-switch.cpp | 69 +++++
clang/test/CIR/Lowering/str.c | 9 +
clang/test/CIR/Lowering/switch-while.c | 84 ++++++
clang/test/CIR/hello.c | 5 +
clang/test/CIR/test.c | 1 +
48 files changed, 1681 insertions(+)
create mode 100644 clang/test/CIR/CodeGen/OpenMP/taskwait.cpp
create mode 100644 clang/test/CIR/CodeGen/StringExample.cpp
create mode 100644 clang/test/CIR/CodeGen/binassign.cpp
create mode 100644 clang/test/CIR/CodeGen/bswap.cpp
create mode 100644 clang/test/CIR/CodeGen/c89-implicit-int.c
create mode 100644 clang/test/CIR/CodeGen/comma.cpp
create mode 100644 clang/test/CIR/CodeGen/complex-cast.c
create mode 100644 clang/test/CIR/CodeGen/compound-literal-empty.c
create mode 100644 clang/test/CIR/CodeGen/expressions.cpp
create mode 100644 clang/test/CIR/CodeGen/func_dsolocal_pie.c
create mode 100644 clang/test/CIR/CodeGen/gnu89.c
create mode 100644 clang/test/CIR/CodeGen/if-constexpr.cpp
create mode 100644 clang/test/CIR/CodeGen/implicit-return.cpp
create mode 100644 clang/test/CIR/CodeGen/inc-bool.cpp
create mode 100644 clang/test/CIR/CodeGen/inc-dec.cpp
create mode 100644 clang/test/CIR/CodeGen/lalg.c
create mode 100644 clang/test/CIR/CodeGen/literals.c
create mode 100644 clang/test/CIR/CodeGen/literals.cpp
create mode 100644 clang/test/CIR/CodeGen/loop-scope.cpp
create mode 100644 clang/test/CIR/CodeGen/lvalue-refs.cpp
create mode 100644 clang/test/CIR/CodeGen/ms-intrinsics-other.c
create mode 100644 clang/test/CIR/CodeGen/no-pie.c
create mode 100644 clang/test/CIR/CodeGen/no-proto-fun-ptr.c
create mode 100644 clang/test/CIR/CodeGen/no-proto-is-void.cpp
create mode 100644 clang/test/CIR/CodeGen/null-arithmatic-expression.c
create mode 100644 clang/test/CIR/CodeGen/operators.cpp
create mode 100644 clang/test/CIR/CodeGen/optimization-attr.cpp
create mode 100644 clang/test/CIR/CodeGen/pointer.cpp
create mode 100644 clang/test/CIR/CodeGen/return.cpp
create mode 100644 clang/test/CIR/CodeGen/shift.cpp
create mode 100644 clang/test/CIR/CodeGen/spelling-locations.cpp
create mode 100644 clang/test/CIR/CodeGen/std-array.cpp
create mode 100644 clang/test/CIR/CodeGen/stmt-expr.c
create mode 100644 clang/test/CIR/CodeGen/store.c
create mode 100644 clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
create mode 100644 clang/test/CIR/CodeGen/trap.cpp
create mode 100644 clang/test/CIR/CodeGen/types-IEEE-quad.c
create mode 100644 clang/test/CIR/CodeGen/types-nullptr.cpp
create mode 100644 clang/test/CIR/CodeGen/types.c
create mode 100644 clang/test/CIR/CodeGen/unary.c
create mode 100644 clang/test/CIR/CodeGen/unreachable.cpp
create mode 100644 clang/test/CIR/Lowering/bitfieils.c
create mode 100644 clang/test/CIR/Lowering/global-ptr.c
create mode 100644 clang/test/CIR/Lowering/nested-switch.cpp
create mode 100644 clang/test/CIR/Lowering/str.c
create mode 100644 clang/test/CIR/Lowering/switch-while.c
create mode 100644 clang/test/CIR/hello.c
create mode 100644 clang/test/CIR/test.c
diff --git a/clang/test/CIR/CodeGen/OpenMP/taskwait.cpp b/clang/test/CIR/CodeGen/OpenMP/taskwait.cpp
new file mode 100644
index 0000000000000..3b2059a8b9655
--- /dev/null
+++ b/clang/test/CIR/CodeGen/OpenMP/taskwait.cpp
@@ -0,0 +1,9 @@
+// TODO: fix crash in emitTaskWaitCall
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fopenmp-enable-irbuilder -fopenmp -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+// CHECK: cir.func
+void omp_taskwait_1(){
+// CHECK-DISABLE: omp.taskwait
+// #pragma omp taskwait
+}
diff --git a/clang/test/CIR/CodeGen/StringExample.cpp b/clang/test/CIR/CodeGen/StringExample.cpp
new file mode 100644
index 0000000000000..a2c0ef374f1ca
--- /dev/null
+++ b/clang/test/CIR/CodeGen/StringExample.cpp
@@ -0,0 +1,34 @@
+// RUN: true
+
+int strlen(char const *);
+void puts(char const *);
+
+struct String {
+ long size;
+ long capacity;
+ char *storage;
+
+ String() : size{0}, capacity{0}, storage{nullptr} {}
+ String(char const *s) : size{strlen(s)}, capacity{size},
+ storage{new char[capacity]} {}
+};
+
+struct StringView {
+ long size;
+ char *storage;
+
+ StringView(const String &s) : size{s.size}, storage{s.storage} {}
+ StringView() : size{0}, storage{nullptr} {}
+};
+
+int main() {
+ StringView sv;
+ {
+ String s = "Hi";
+ sv = s;
+
+ puts(sv.storage);
+ }
+
+ puts(sv.storage);
+}
diff --git a/clang/test/CIR/CodeGen/binassign.cpp b/clang/test/CIR/CodeGen/binassign.cpp
new file mode 100644
index 0000000000000..934742d13404a
--- /dev/null
+++ b/clang/test/CIR/CodeGen/binassign.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+int foo(int a, int b) {
+ int x = a * b;
+ x *= b;
+ x /= b;
+ x %= b;
+ x += b;
+ x -= b;
+ x >>= b;
+ x <<= b;
+ x &= b;
+ x ^= b;
+ x |= b;
+ return x;
+}
+
+// CHECK: [[Value:%[0-9]+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
+// CHECK: = cir.binop(mul,
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.binop(mul,
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: cir.binop(div,
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.binop(rem, {{.*}} loc([[SourceLocation:#loc[0-9]+]])
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.binop(add,
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.binop(sub,
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.shift(right
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.shift(left
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.binop(and,
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.binop(xor,
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+// CHECK: = cir.load {{.*}}[[Value]]
+// CHECK: = cir.binop(or,
+// CHECK: cir.store{{.*}} {{.*}}[[Value]]
+
+typedef enum {
+ A = 3,
+} enumy;
+
+enumy getty();
+
+void exec() {
+ enumy r;
+ if ((r = getty()) < 0) {}
+}
+
+// CHECK: cir.func dso_local @_Z4execv()
+// CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["r"] {alignment = 4 : i64}
+// CHECK: cir.scope {
+// CHECK: %1 = cir.call @_Z5gettyv() : () -> !u32i
+// CHECK: cir.store{{.*}} %1, %0 : !u32i, !cir.ptr<!u32i>
+// CHECK: %2 = cir.cast(integral, %1 : !u32i), !s32i
+// CHECK: %3 = cir.const #cir.int<0> : !s32i
+// CHECK: %4 = cir.cmp(lt, %2, %3) : !s32i, !cir.bool
+// CHECK: cir.if %4 {
+
+// CHECK: [[SourceLocationB:#loc[0-9]+]] = loc("{{.*}}binassign.cpp":8:8)
+// CHECK: [[SourceLocationA:#loc[0-9]+]] = loc("{{.*}}binassign.cpp":8:3)
+// CHECK: [[SourceLocation]] = loc(fused[[[SourceLocationA]], [[SourceLocationB]]])
diff --git a/clang/test/CIR/CodeGen/bswap.cpp b/clang/test/CIR/CodeGen/bswap.cpp
new file mode 100644
index 0000000000000..3473b64ac7228
--- /dev/null
+++ b/clang/test/CIR/CodeGen/bswap.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+using u16 = unsigned short;
+using u32 = unsigned int;
+using u64 = unsigned long long;
+
+u16 bswap_u16(u16 x) {
+ return __builtin_bswap16(x);
+}
+
+// CHECK: cir.func dso_local @_Z9bswap_u16t
+// CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u16i
+// CHECK: }
+
+u32 bswap_u32(u32 x) {
+ return __builtin_bswap32(x);
+}
+
+// CHECK: cir.func dso_local @_Z9bswap_u32j
+// CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u32i
+// CHECK: }
+
+u64 bswap_u64(u64 x) {
+ return __builtin_bswap64(x);
+}
+
+// CHECK: cir.func dso_local @_Z9bswap_u64y
+// CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u64i
+// CHECK: }
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..4e2392c44a802
--- /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 dso_local @func() -> !s32i
+ return 0;
+}
diff --git a/clang/test/CIR/CodeGen/comma.cpp b/clang/test/CIR/CodeGen/comma.cpp
new file mode 100644
index 0000000000000..e10be4ac02288
--- /dev/null
+++ b/clang/test/CIR/CodeGen/comma.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+int c0() {
+ int a = 1;
+ int b = 2;
+ return b + 1, a;
+}
+
+// CHECK: cir.func dso_local @_Z2c0v() -> !s32i
+// CHECK: %[[#RET:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
+// CHECK: %[[#A:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init]
+// CHECK: %[[#B:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["b", init]
+// CHECK: %[[#LOADED_B:]] = cir.load{{.*}} %[[#B]] : !cir.ptr<!s32i>, !s32i
+// CHECK: %[[#]] = cir.binop(add, %[[#LOADED_B]], %[[#]]) nsw : !s32i
+// CHECK: %[[#LOADED_A:]] = cir.load{{.*}} %[[#A]] : !cir.ptr<!s32i>, !s32i
+// CHECK: cir.store{{.*}} %[[#LOADED_A]], %[[#RET]] : !s32i, !cir.ptr<!s32i>
+
+int &foo1();
+int &foo2();
+
+void c1() {
+ int &x = (foo1(), foo2());
+}
+
+// CHECK: cir.func dso_local @_Z2c1v()
+// CHECK: %0 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
+// CHECK: %1 = cir.call @_Z4foo1v() : () -> !cir.ptr<!s32i>
+// CHECK: %2 = cir.call @_Z4foo2v() : () -> !cir.ptr<!s32i>
+// CHECK: cir.store{{.*}} %2, %0 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
diff --git a/clang/test/CIR/CodeGen/complex-cast.c b/clang/test/CIR/CodeGen/complex-cast.c
new file mode 100644
index 0000000000000..5212625694447
--- /dev/null
+++ b/clang/test/CIR/CodeGen/complex-cast.c
@@ -0,0 +1,264 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -mmlir --mlir-print-ir-before=cir-lowering-prepare -o %t.cir %s 2>&1 | FileCheck --check-prefixes=CIR-BEFORE,CHECK %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -mmlir --mlir-print-ir-after=cir-lowering-prepare -o %t.cir %s 2>&1 | FileCheck --check-prefixes=CIR-AFTER,CHECK %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm -o %t.ll %s
+// RUN: FileCheck --input-file=%t.ll --check-prefixes=LLVM,CHECK %s
+
+#include <stdbool.h>
+
+volatile double _Complex cd;
+volatile float _Complex cf;
+volatile int _Complex ci;
+volatile short _Complex cs;
+volatile double sd;
+volatile int si;
+volatile bool b;
+
+void scalar_to_complex() {
+ cd = sd;
+ ci = si;
+ cd = si;
+ ci = sd;
+}
+
+// CHECK-LABEL: @scalar_to_complex()
+
+// CIR-BEFORE: %{{.+}} = cir.cast(float_to_complex, %{{.+}} : !cir.double), !cir.complex<!cir.double>
+
+// CIR-AFTER: %[[#REAL:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!cir.double>, !cir.double
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
+
+// CIR-BEFORE: %{{.+}} = cir.cast(int_to_complex, %{{.+}} : !s32i), !cir.complex<!s32i>
+
+// CIR-AFTER: %[[#REAL:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!s32i>, !s32i
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
+
+// CIR-BEFORE: %[[#A:]] = cir.cast(int_to_float, %{{.+}} : !s32i), !cir.double
+// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(float_to_complex, %[[#A]] : !cir.double), !cir.complex<!cir.double>
+
+// CIR-AFTER: %[[#A:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!s32i>, !s32i
+// CIR-AFTER-NEXT: %[[#REAL:]] = cir.cast(int_to_float, %[[#A]] : !s32i), !cir.double
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
+
+// CIR-BEFORE: %[[#A:]] = cir.cast(float_to_int, %{{.+}} : !cir.double), !s32i
+// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(int_to_complex, %[[#A]] : !s32i), !cir.complex<!s32i>
+
+// CIR-AFTER: %[[#A:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!cir.double>, !cir.double
+// CIR-AFTER-NEXT: %[[#REAL:]] = cir.cast(float_to_int, %[[#A]] : !cir.double), !s32i
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
+
+// LLVM: %[[#REAL:]] = load volatile double, ptr @sd, align 8
+// LLVM-NEXT: %[[#A:]] = insertvalue { double, double } {{.*}}, double %[[#REAL]], 0
+// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double 0.000000e+00, 1
+
+// LLVM: %[[#REAL:]] = load volatile i32, ptr @si, align 4
+// LLVM-NEXT: %[[#A:]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL]], 0
+// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 0, 1
+
+// LLVM: %[[#A:]] = load volatile i32, ptr @si, align 4
+// LLVM-NEXT: %[[#REAL:]] = sitofp i32 %[[#A]] to double
+// LLVM-NEXT: %[[#B:]] = insertvalue { double, double } {{.*}}, double %[[#REAL]], 0
+// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#B]], double 0.000000e+00, 1
+
+// LLVM: %[[#A:]] = load volatile double, ptr @sd, align 8
+// LLVM-NEXT: %[[#REAL:]] = fptosi double %[[#A]] to i32
+// LLVM-NEXT: %[[#B:]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL]], 0
+// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#B]], i32 0, 1
+
+// CHECK: }
+
+void scalar_to_complex_explicit() {
+ cd = (double _Complex)sd;
+ ci = (int _Complex)si;
+ cd = (double _Complex)si;
+ ci = (int _Complex)sd;
+}
+
+// CHECK-LABEL: @scalar_to_complex_explicit()
+
+// CIR-BEFORE: %{{.+}} = cir.cast(float_to_complex, %{{.+}} : !cir.double), !cir.complex<!cir.double>
+
+// CIR-AFTER: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %{{.+}}, %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
+
+// LLVM: %[[#A:]] = insertvalue { double, double } {{.*}}, double %{{.+}}, 0
+// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double 0.000000e+00, 1
+
+// CIR-BEFORE: %{{.+}} = cir.cast(int_to_complex, %{{.+}} : !s32i), !cir.complex<!s32i>
+
+// CIR-AFTER: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %{{.+}}, %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
+
+// LLVM: %[[#A:]] = insertvalue { i32, i32 } {{.*}}, i32 %{{.+}}, 0
+// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 0, 1
+
+// CIR-BEFORE: %[[#A:]] = cir.cast(int_to_float, %{{.+}} : !s32i), !cir.double
+// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(float_to_complex, %[[#A]] : !cir.double), !cir.complex<!cir.double>
+
+// CIR-AFTER: %[[#REAL:]] = cir.cast(int_to_float, %11 : !s32i), !cir.double
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
+
+// LLVM: %[[#REAL:]] = sitofp i32 %{{.+}} to double
+// LLVM-NEXT: %[[#A:]] = insertvalue { double, double } {{.*}}, double %[[#REAL]], 0
+// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double 0.000000e+00, 1
+
+// CIR-BEFORE: %[[#A:]] = cir.cast(float_to_int, %{{.+}} : !cir.double), !s32i
+// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(int_to_complex, %[[#A]] : !s32i), !cir.complex<!s32i>
+
+// CIR-AFTER: %[[#REAL:]] = cir.cast(float_to_int, %{{.+}} : !cir.double), !s32i
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
+// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
+
+// LLVM: %[[#REAL:]] = fptosi double %{{.+}} to i32
+// LLVM-NEXT: %[[#A:]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL]], 0
+// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 0, 1
+
+// CHECK: }
+
+void complex_to_scalar() {
+ sd = (double)cd;
+ si = (int)ci;
+ sd = (double)ci;
+ si = (int)cd;
+}
+
+// CHECK-LABEL: @complex_to_scalar()
+
+// CIR-BEFORE: %{{.+}} = cir.cast(float_complex_to_real, %{{.+}} : !cir.complex<!cir.double>), !cir.double
+
+// CIR-AFTER: %{{.+}} = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
+
+// LLVM: %{{.+}} = extractvalue { double, double } %{{.+}}, 0
+
+// CIR-BEFORE: %{{.+}} = cir.cast(int_complex_to_real, %{{.+}} : !cir.complex<!s32i>), !s32i
+
+// CIR-AFTER: %{{.+}} = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
+
+// LLVM: %{{.+}} = extractvalue { i32, i32 } %{{.+}}, 0
+
+// CIR-BEFORE: %[[#A:]] = cir.cast(int_complex_to_real, %{{.+}} : !cir.complex<!s32i>), !s32i
+// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(int_to_float, %[[#A]] : !s32i), !cir.double
+
+// CIR-AFTER: %[[#A:]] = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
+// CIR-AFTER-NEXT: %{{.+}} = cir.cast(int_to_float, %[[#A]] : !s32i), !cir.double
+
+// LLVM: %[[#A:]] = extractvalue { i32, i32 } %{{.+}}, 0
+// LLVM-NEXT: %{{.+}} = sitofp i32 %[[#A]] to double
+
+// CIR-BEFORE: %[[#A:]] = cir.cast(float_complex_to_real, %{{.+}} : !cir.complex<!cir.double>), !cir.double
+// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(float_to_int, %[[#A]] : !cir.double), !s32i
+
+// CIR-AFTER: %[[#A:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
+// CIR-AFTER-NEXT: %{{.+}} = cir.cast(float_to_int, %[[#A]] : !cir.double), !s32i
+
+// LLVM: %[[#A:]] = extractvalue { double, double } %{{.+}}, 0
+// LLVM-NEXT: %{{.+}} = fptosi double %[[#A]] to i32
+
+// CHECK: }
+
+void complex_to_bool() {
+ b = (bool)cd;
+ b = (bool)ci;
+}
+
+// CHECK-LABEL: @complex_to_bool()
+
+// CIR-BEFORE: %{{.+}} = cir.cast(float_complex_to_bool, %{{.+}} : !cir.complex<!cir.double>), !cir.bool
+
+// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.complex.imag %{{.+}} : !cir.complex<!cir.double> -> !cir.double
+// CIR-AFTER-NEXT: %[[#RB:]] = cir.cast(float_to_bool, %[[#REAL]] : !cir.double), !cir.bool
+// CIR-AFTER-NEXT: %[[#IB:]] = cir.cast(float_to_bool, %[[#IMAG]] : !cir.double), !cir.bool
+// CIR-AFTER-NEXT: %[[#A:]] = cir.const #true
+// CIR-AFTER-NEXT: %{{.+}} = cir.select if %[[#RB]] then %[[#A]] else %[[#IB]] : (!cir.bool, !cir.bool, !cir.bool) -> !cir.bool
+
+// LLVM: %[[#REAL:]] = extractvalue { double, double } %{{.+}}, 0
+// LLVM-NEXT: %[[#IMAG:]] = extractvalue { double, double } %{{.+}}, 1
+// LLVM-NEXT: %[[#RB:]] = fcmp une double %[[#REAL]], 0.000000e+00
+// LLVM-NEXT: %[[#IB:]] = fcmp une double %[[#IMAG]], 0.000000e+00
+// LLVM-NEXT: %{{.+}} = or i1 %[[#RB]], %[[#IB]]
+
+// CIR-BEFORE: %{{.+}} = cir.cast(int_complex_to_bool, %{{.+}} : !cir.complex<!s32i>), !cir.bool
+
+// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
+// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.complex.imag %{{.+}} : !cir.complex<!s32i> -> !s32i
+// CIR-AFTER-NEXT: %[[#RB:]] = cir.cast(int_to_bool, %[[#REAL]] : !s32i), !cir.bool
+// CIR-AFTER-NEXT: %[[#IB:]] = cir.cast(int_to_bool, %[[#IMAG]] : !s32i), !cir.bool
+// CIR-AFTER-NEXT: %[[#A:]] = cir.const #true
+// CIR-AFTER-NEXT: %{{.+}} = cir.select if %[[#RB]] then %[[#A]] else %[[#IB]] : (!cir.bool, !cir.bool, !cir.bool) -> !cir.bool
+
+// LLVM: %[[#REAL:]] = extractvalue { i32, i32 } %{{.+}}, 0
+// LLVM-NEXT: %[[#IMAG:]] = extractvalue { i32, i32 } %{{.+}}, 1
+// LLVM-NEXT: %[[#RB:]] = icmp ne i32 %[[#REAL]], 0
+// LLVM-NEXT: %[[#IB:]] = icmp ne i32 %[[#IMAG]], 0
+// LLVM-NEXT: %{{.+}} = or i1 %[[#RB]], %[[#IB]]
+
+// CHECK: }
+
+struct CX {
+ double real;
+ double imag;
+};
+
+void lvalue_to_rvalue_bitcast() {
+ struct CX a;
+ double _Complex b = __builtin_bit_cast(double _Complex, a);
+}
+
+// CHECK-LABEL: @lvalue_to_rvalue_bitcast()
+
+// CIR-BEFORE: %{{.+}} = cir.cast(bitcast, %{{.+}} : !cir.ptr<!rec_CX>), !cir.ptr<!cir.complex<!cir.double>>
+
+// CIR-AFTER: %{{.+}} = cir.cast(bitcast, %{{.+}} : !cir.ptr<!rec_CX>), !cir.ptr<!cir.complex<!cir.double>>
+
+// LLVM: %[[PTR_ADDR:.*]] = alloca %struct.CX, i64 1, align 8
+// LLVM: %[[COMPLEX_ADDR:.*]] = alloca { double, double }, i64 1, align 8
+// LLVM: %[[PTR_TO_COMPLEX:.*]] = load { double, double }, ptr %[[PTR_ADDR]], align 8
+// LLVM: store { double, double } %[[PTR_TO_COMPLEX]], ptr %[[COMPLEX_ADDR]], align 8
+
+// CHECK: }
+
+void complex_to_complex_cast() {
+ cd = cf;
+ ci = cs;
+}
+
+// CIR-BEFORE: %[[TMP:.*]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>
+// CIR-BEFORE: %[[FP_COMPLEX:.*]] = cir.cast(float_complex, %[[TMP]] : !cir.complex<!cir.float>), !cir.complex<!cir.double>
+
+// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.*}} : !cir.complex<!cir.float> -> !cir.float
+// CIR-AFTER: %[[#IMAG:]] = cir.complex.imag %{{.*}} : !cir.complex<!cir.float> -> !cir.float
+// CIR-AFTER: %[[#REAL_FP_CAST:]] = cir.cast(floating, %[[#REAL]] : !cir.float), !cir.double
+// CIR-AFTER: %[[#IMAG_FP_CAST:]] = cir.cast(floating, %[[#IMAG]] : !cir.float), !cir.double
+// CIR-AFTER: %{{.*}} = cir.complex.create %[[#REAL_FP_CAST]], %[[#IMAG_FP_CAST]] : !cir.double -> !cir.complex<!cir.double>
+
+// LLVM: %[[#REAL:]] = extractvalue { float, float } %{{.*}}, 0
+// LLVM: %[[#IMAG:]] = extractvalue { float, float } %{{.*}}, 1
+// LLVM: %[[#REAL_FP_CAST:]] = fpext float %[[#REAL]] to double
+// LLVM: %[[#IMAG_FP_CAST:]] = fpext float %[[#IMAG]] to double
+// LLVM: %[[TMP:.*]] = insertvalue { double, double } {{.*}}, double %[[#REAL_FP_CAST]], 0
+// LLVM: %{{.*}} = insertvalue { double, double } %[[TMP]], double %[[#IMAG_FP_CAST]], 1
+
+// CIR-BEFORE: %[[TMP:.*]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!cir.complex<!s16i>>, !cir.complex<!s16i>
+// CIR-BEFORE: %[[INT_COMPLEX:.*]] = cir.cast(int_complex, %[[TMP]] : !cir.complex<!s16i>), !cir.complex<!s32i>
+
+// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.*}} : !cir.complex<!s16i> -> !s16i
+// CIR-AFTER: %[[#IMAG:]] = cir.complex.imag %{{.*}} : !cir.complex<!s16i> -> !s16i
+// CIR-AFTER: %[[#REAL_INT_CAST:]] = cir.cast(integral, %[[#REAL]] : !s16i), !s32i
+// CIR-AFTER: %[[#IMAG_INT_CAST:]] = cir.cast(integral, %[[#IMAG]] : !s16i), !s32i
+// CIR-AFTER: %{{.*}} = cir.complex.create %[[#REAL_INT_CAST]], %[[#IMAG_INT_CAST]] : !s32i -> !cir.complex<!s32i>
+
+// LLVM: %[[#REAL:]] = extractvalue { i16, i16 } %{{.*}}, 0
+// LLVM: %[[#IMAG:]] = extractvalue { i16, i16 } %{{.*}}, 1
+// LLVM: %[[#REAL_INT_CAST:]] = sext i16 %[[#REAL]] to i32
+// LLVM: %[[#IMAG_INT_CAST:]] = sext i16 %[[#IMAG]] to i32
+// LLVM: %[[TMP:.*]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL_INT_CAST]], 0
+// LLVM: %{{.*}} = insertvalue { i32, i32 } %[[TMP]], i32 %[[#IMAG_INT_CAST]], 1
+
+void promotion() {
+ cd = cf + cf;
+}
diff --git a/clang/test/CIR/CodeGen/compound-literal-empty.c b/clang/test/CIR/CodeGen/compound-literal-empty.c
new file mode 100644
index 0000000000000..b0007d96b4cb2
--- /dev/null
+++ b/clang/test/CIR/CodeGen/compound-literal-empty.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+short b() { return (short){}; }
+
+// CIR-LABEL: b
+// CIR: {{%.*}} = cir.alloca !s16i, !cir.ptr<!s16i>, [".compoundliteral"] {alignment = 2 : i64}
+
+// LLVM-LABEL: b
+// LLVM: [[RET_P:%.*]] = alloca i16, i64 1, align 2
+// LLVM: [[LITERAL:%.*]] = alloca i16, i64 1, align 2
+// LLVM: store i16 0, ptr [[LITERAL]], align 2
+// LLVM: [[T0:%.*]] = load i16, ptr [[LITERAL]], align 2
+// LLVM: store i16 [[T0]], ptr [[RET_P]], align 2
+// LLVM: [[T1:%.*]] = load i16, ptr [[RET_P]], align 2
+// LLVM: ret i16 [[T1]]
diff --git a/clang/test/CIR/CodeGen/expressions.cpp b/clang/test/CIR/CodeGen/expressions.cpp
new file mode 100644
index 0000000000000..7324c1357f8ab
--- /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 dso_local @{{.+}}test
+
+ // Should generate LValue parenthesis expression.
+ (a) = 1;
+ // CHECK: %[[#C:]] = cir.const #cir.int<1> : !s32i
+ // CHECK: cir.store{{.*}} %[[#C]], %{{.+}} : !s32i, !cir.ptr<!s32i>
+}
diff --git a/clang/test/CIR/CodeGen/func_dsolocal_pie.c b/clang/test/CIR/CodeGen/func_dsolocal_pie.c
new file mode 100644
index 0000000000000..f3e524ce2fdb3
--- /dev/null
+++ b/clang/test/CIR/CodeGen/func_dsolocal_pie.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir -pic-is-pie -pic-level 1 %s -o %t1.cir
+// RUN: FileCheck --input-file=%t1.cir %s -check-prefix=CIR
+// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm -pic-is-pie -pic-level 1 %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+void foo(int i) {
+
+}
+
+int main() {
+ foo(2);
+ return 0;
+}
+
+// CIR: cir.func dso_local @foo(%arg0: !s32i
+// CIR-NEXT: [[TMP0:%.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
+// CIR-NEXT: cir.store %arg0, [[TMP0]] : !s32i, !cir.ptr<!s32i>
+// CIR-NEXT: cir.return
+
+// CIR: cir.func no_proto dso_local @main() -> !s32i
+// CIR: [[TMP1:%.*]] = cir.const #cir.int<2> : !s32i
+// CIR: cir.call @foo([[TMP1]]) : (!s32i) -> ()
+
+// LLVM: define dso_local void @foo(i32 [[TMP3:%.*]])
+// LLVM: [[ARG_STACK:%.*]] = alloca i32, i64 1, align 4
+// LLVM: store i32 [[TMP3]], ptr [[ARG_STACK]], align 4
+// LLVM: ret void
+
+// LLVM: define dso_local i32 @main()
+// LLVM: [[TMP4:%.*]] = alloca i32, i64 1, align 4
+// LLVM: call void @foo(i32 2)
+// LLVM: store i32 0, ptr [[TMP4]], align 4
+// LLVM: [[RET_VAL:%.*]] = load i32, ptr [[TMP4]], align 4
+// LLVM: ret i32 [[RET_VAL]]
diff --git a/clang/test/CIR/CodeGen/gnu89.c b/clang/test/CIR/CodeGen/gnu89.c
new file mode 100644
index 0000000000000..5254576779aa1
--- /dev/null
+++ b/clang/test/CIR/CodeGen/gnu89.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -std=gnu89 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+void foo() {}
+//CHECK: cir.func {{.*@foo}}
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/if-constexpr.cpp b/clang/test/CIR/CodeGen/if-constexpr.cpp
new file mode 100644
index 0000000000000..dd13591be17f4
--- /dev/null
+++ b/clang/test/CIR/CodeGen/if-constexpr.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+void if0() {
+ int x = 0;
+ if constexpr (0 == 0) {
+ // Declare a variable with same name to be sure we handle the
+ // scopes correctly
+ int x = 2;
+ } else {
+ int x = 3;
+ }
+ if constexpr (0 == 1) {
+ int x = 4;
+ } else {
+ int x = 5;
+ }
+ if constexpr (int x = 7; 8 == 8) {
+ int y = x;
+ } else {
+ int y = 2*x;
+ }
+ if constexpr (int x = 9; 8 == 10) {
+ int y = x;
+ } else {
+ int y = 3*x;
+ }
+ if constexpr (10 == 10) {
+ int x = 20;
+ }
+ if constexpr (10 == 11) {
+ int x = 30;
+ }
+ if constexpr (int x = 70; 80 == 80) {
+ int y = 10*x;
+ }
+ if constexpr (int x = 90; 80 == 100) {
+ int y = 11*x;
+ }
+}
+
+// CHECK: cir.func dso_local @_Z3if0v() {{.*}}
+// CHECK: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: cir.scope {
+// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
+// CHECK-NEXT: %3 = cir.const #cir.int<2> : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: } loc({{.*}})
+// CHECK-NEXT: cir.scope {
+// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
+// CHECK-NEXT: %3 = cir.const #cir.int<5> : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: } loc({{.*}})
+// CHECK-NEXT: cir.scope {
+// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
+// CHECK-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init] {{.*}}
+// CHECK-NEXT: %4 = cir.const #cir.int<7> : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %4, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: %5 = cir.load{{.*}} %2 : !cir.ptr<!s32i>, !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %5, %3 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: } loc({{.*}})
+// CHECK-NEXT: cir.scope {
+// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
+// CHECK-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init] {{.*}}
+// CHECK-NEXT: %4 = cir.const #cir.int<9> : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %4, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: %5 = cir.const #cir.int<3> : !s32i loc({{.*}})
+// CHECK-NEXT: %6 = cir.load{{.*}} %2 : !cir.ptr<!s32i>, !s32i loc({{.*}})
+// CHECK-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %7, %3 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: } loc({{.*}})
+// CHECK-NEXT: cir.scope {
+// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
+// CHECK-NEXT: %3 = cir.const #cir.int<20> : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: } loc({{.*}})
+// CHECK-NEXT: cir.scope {
+// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
+// CHECK-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init] {{.*}}
+// CHECK-NEXT: %4 = cir.const #cir.int<70> : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %4, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: %5 = cir.const #cir.int<10> : !s32i loc({{.*}})
+// CHECK-NEXT: %6 = cir.load{{.*}} %2 : !cir.ptr<!s32i>, !s32i loc({{.*}})
+// CHECK-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %7, %3 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: } loc({{.*}})
+// CHECK-NEXT: cir.scope {
+// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
+// CHECK-NEXT: %3 = cir.const #cir.int<90> : !s32i loc({{.*}})
+// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
+// CHECK-NEXT: } loc({{.*}})
+// CHECK-NEXT: cir.return loc({{.*}})
diff --git a/clang/test/CIR/CodeGen/implicit-return.cpp b/clang/test/CIR/CodeGen/implicit-return.cpp
new file mode 100644
index 0000000000000..d53568d522de0
--- /dev/null
+++ b/clang/test/CIR/CodeGen/implicit-return.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -O0 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CHECK-O0
+// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CHECK-O2
+
+void ret_void() {}
+
+// CHECK-O0: cir.func dso_local @_Z8ret_voidv()
+// CHECK-O0-NEXT: cir.return
+// CHECK-O0-NEXT: }
+
+// CHECK-O2: cir.func dso_local @_Z8ret_voidv()
+// CHECK-O2-NEXT: cir.return
+// CHECK-O2-NEXT: }
+
+int ret_non_void() {}
+
+// CHECK-O0: cir.func dso_local @_Z12ret_non_voidv() -> !s32i
+// CHECK-O0-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
+// CHECK-O0-NEXT: cir.trap
+// CHECK-O0-NEXT: }
+
+// CHECK-O2: cir.func dso_local @_Z12ret_non_voidv() -> !s32i
+// CHECK-O2-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
+// CHECK-O2-NEXT: cir.unreachable
+// CHECK-O2-NEXT: }
diff --git a/clang/test/CIR/CodeGen/inc-bool.cpp b/clang/test/CIR/CodeGen/inc-bool.cpp
new file mode 100644
index 0000000000000..17557d338ce0a
--- /dev/null
+++ b/clang/test/CIR/CodeGen/inc-bool.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++14 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+void foo(bool x) {
+ x++;
+}
+
+// CHECK: cir.func dso_local @_Z3foob(%arg0: !cir.bool loc({{.*}}))
+// CHECK: [[ALLOC_X:%.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init] {alignment = 1 : i64}
+// CHECK: cir.store{{.*}} %arg0, [[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
+// CHECK: {{.*}} = cir.load{{.*}} [[ALLOC_X]] : !cir.ptr<!cir.bool>, !cir.bool
+// CHECK: [[TRUE:%.*]] = cir.const #true
+// CHECK: cir.store{{.*}} [[TRUE]], [[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
+// CHECK: cir.return
diff --git a/clang/test/CIR/CodeGen/inc-dec.cpp b/clang/test/CIR/CodeGen/inc-dec.cpp
new file mode 100644
index 0000000000000..c8aa62198c819
--- /dev/null
+++ b/clang/test/CIR/CodeGen/inc-dec.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+unsigned id0() {
+ unsigned a = 1;
+ return ++a;
+}
+
+// CHECK: cir.func dso_local @_Z3id0v() -> !u32i
+// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
+// CHECK: %[[#AFTER_A:]] = cir.unary(inc, %[[#BEFORE_A]])
+// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
+// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#RET]]
+
+
+unsigned id1() {
+ unsigned a = 1;
+ return --a;
+}
+
+// CHECK: cir.func dso_local @_Z3id1v() -> !u32i
+// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
+// CHECK: %[[#AFTER_A:]] = cir.unary(dec, %[[#BEFORE_A]])
+// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
+// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#RET]]
+
+unsigned id2() {
+ unsigned a = 1;
+ return a++;
+}
+
+// CHECK: cir.func dso_local @_Z3id2v() -> !u32i
+// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
+// CHECK: %[[#AFTER_A:]] = cir.unary(inc, %[[#BEFORE_A]])
+// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
+// CHECK: cir.store{{.*}} %[[#BEFORE_A]], %[[#RET]]
+
+unsigned id3() {
+ unsigned a = 1;
+ return a--;
+}
+
+// CHECK: cir.func dso_local @_Z3id3v() -> !u32i
+// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
+// CHECK: %[[#AFTER_A:]] = cir.unary(dec, %[[#BEFORE_A]])
+// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
+// CHECK: cir.store{{.*}} %[[#BEFORE_A]], %[[#RET]]
diff --git a/clang/test/CIR/CodeGen/lalg.c b/clang/test/CIR/CodeGen/lalg.c
new file mode 100644
index 0000000000000..7a086e9d059d1
--- /dev/null
+++ b/clang/test/CIR/CodeGen/lalg.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o - | FileCheck %s
+
+double dot() {
+ double x = 0.0;
+ double y = 0.0f;
+ double result = x * y;
+ return result;
+}
+
+// CHECK: %1 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["x", init]
+// CHECK-NEXT: %2 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["y", init]
+// CHECK-NEXT: %3 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["result", init]
+// CHECK-NEXT: %4 = cir.const #cir.fp<0.000000e+00> : !cir.double
+// CHECK-NEXT: cir.store{{.*}} %4, %1 : !cir.double, !cir.ptr<!cir.double>
+// CHECK-NEXT: %5 = cir.const #cir.fp<0.000000e+00> : !cir.float
+// CHECK-NEXT: %6 = cir.cast(floating, %5 : !cir.float), !cir.double
+// CHECK-NEXT: cir.store{{.*}} %6, %2 : !cir.double, !cir.ptr<!cir.double>
+// CHECK-NEXT: %7 = cir.load{{.*}} %1 : !cir.ptr<!cir.double>, !cir.double
+// CHECK-NEXT: %8 = cir.load{{.*}} %2 : !cir.ptr<!cir.double>, !cir.double
+// CHECK-NEXT: %9 = cir.binop(mul, %7, %8) : !cir.double
diff --git a/clang/test/CIR/CodeGen/literals.c b/clang/test/CIR/CodeGen/literals.c
new file mode 100644
index 0000000000000..b8a33ad115599
--- /dev/null
+++ b/clang/test/CIR/CodeGen/literals.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
+
+int literals(void) {
+ char a = 'a'; // char literals are int in C
+ // CHECK: %[[RES:[0-9]+]] = cir.const #cir.int<97> : !s32i
+ // CHECK: %{{[0-9]+}} = cir.cast(integral, %[[RES]] : !s32i), !s8i
+
+ return 0;
+}
diff --git a/clang/test/CIR/CodeGen/literals.cpp b/clang/test/CIR/CodeGen/literals.cpp
new file mode 100644
index 0000000000000..87290b888185e
--- /dev/null
+++ b/clang/test/CIR/CodeGen/literals.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
+
+int literals() {
+ char a = 'a'; // char literals have char type in C++
+ // CHECK: %{{[0-9]+}} = cir.const #cir.int<97> : !s8i
+
+ return 0;
+}
diff --git a/clang/test/CIR/CodeGen/loop-scope.cpp b/clang/test/CIR/CodeGen/loop-scope.cpp
new file mode 100644
index 0000000000000..cd2cc76426c1f
--- /dev/null
+++ b/clang/test/CIR/CodeGen/loop-scope.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cpp.cir
+// RUN: FileCheck --input-file=%t.cpp.cir %s --check-prefix=CPPSCOPE
+// RUN: %clang_cc1 -x c -std=c11 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.c.cir
+// RUN: FileCheck --input-file=%t.c.cir %s --check-prefix=CSCOPE
+
+void l0(void) {
+ for (int i = 0;;) {
+ int j = 0;
+ }
+}
+
+// CPPSCOPE: cir.func dso_local @_Z2l0v()
+// CPPSCOPE-NEXT: cir.scope {
+// CPPSCOPE-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
+// CPPSCOPE-NEXT: %1 = cir.const #cir.int<0> : !s32i
+// CPPSCOPE-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
+// CPPSCOPE-NEXT: cir.for : cond {
+
+// CPPSCOPE: } body {
+// CPPSCOPE-NEXT: cir.scope {
+// CPPSCOPE-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["j", init] {alignment = 4 : i64}
+
+// CSCOPE: cir.func dso_local @l0()
+// CSCOPE-NEXT: cir.scope {
+// CSCOPE-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
+// CSCOPE-NEXT: %1 = cir.const #cir.int<0> : !s32i
+// CSCOPE-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
+// CSCOPE-NEXT: cir.for : cond {
+
+// CSCOPE: } body {
+// CSCOPE-NEXT: cir.scope {
+// CSCOPE-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["j", init] {alignment = 4 : i64}
diff --git a/clang/test/CIR/CodeGen/lvalue-refs.cpp b/clang/test/CIR/CodeGen/lvalue-refs.cpp
new file mode 100644
index 0000000000000..82799987aaca7
--- /dev/null
+++ b/clang/test/CIR/CodeGen/lvalue-refs.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
+
+struct String {
+ long size;
+};
+
+void split(String &S) {}
+
+// CHECK: cir.func dso_local @_Z5splitR6String(%arg0: !cir.ptr<!rec_String>
+// CHECK: %0 = cir.alloca !cir.ptr<!rec_String>, !cir.ptr<!cir.ptr<!rec_String>>, ["S", init, const]
+
+void foo() {
+ String s;
+ split(s);
+}
+
+// CHECK: cir.func dso_local @_Z3foov()
+// CHECK: %0 = cir.alloca !rec_String, !cir.ptr<!rec_String>, ["s"]
+// CHECK: cir.call @_Z5splitR6String(%0) : (!cir.ptr<!rec_String>) -> ()
diff --git a/clang/test/CIR/CodeGen/ms-intrinsics-other.c b/clang/test/CIR/CodeGen/ms-intrinsics-other.c
new file mode 100644
index 0000000000000..d5c9164c6a4ed
--- /dev/null
+++ b/clang/test/CIR/CodeGen/ms-intrinsics-other.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -ffreestanding -fms-extensions -Wno-implicit-function-declaration -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck %s --check-prefix=CIR --input-file=%t.cir
+// RUN: %clang_cc1 -ffreestanding -fms-extensions -Wno-implicit-function-declaration -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
+// RUN: FileCheck %s --check-prefix=LLVM --input-file=%t.ll
+
+// This test mimics clang/test/CodeGen/ms-intrinsics-other.c, which eventually
+// CIR shall be able to support fully.
+
+unsigned short test__lzcnt16(unsigned short x) {
+ return __lzcnt16(x);
+}
+// CIR-LABEL: test__lzcnt16
+// CIR: {{%.*}} = cir.clz {{%.*}} : !u16i
+// LLVM-LABEL: test__lzcnt16
+// LLVM: {{%.*}} = call i16 @llvm.ctlz.i16(i16 {{%.*}}, i1 false)
+
+unsigned int test__lzcnt(unsigned int x) {
+ return __lzcnt(x);
+}
+// CIR-LABEL: test__lzcnt
+// CIR: {{%.*}} = cir.clz {{%.*}} : !u32i
+// LLVM-LABEL: test__lzcnt
+// LLVM: {{%.*}} = call i32 @llvm.ctlz.i32(i32 {{%.*}}, i1 false)
+
+unsigned __int64 test__lzcnt64(unsigned __int64 x) {
+ return __lzcnt64(x);
+}
+// CIR-LABEL: test__lzcnt64
+// CIR: {{%.*}} = cir.clz {{%.*}} : !u64i
+// LLVM-LABEL: test__lzcnt64
+// LLVM: {{%.*}} = call i64 @llvm.ctlz.i64(i64 {{%.*}}, i1 false)
+
+unsigned short test__popcnt16(unsigned short x) {
+ return __popcnt16(x);
+}
+// CIR-LABEL: test__popcnt16
+// CIR: {{%.*}} = cir.popcount {{%.*}} : !u16i
+// LLVM-LABEL: test__popcnt16
+// LLVM: {{%.*}} = call i16 @llvm.ctpop.i16(i16 {{%.*}})
+
+unsigned int test__popcnt(unsigned int x) {
+ return __popcnt(x);
+}
+// CIR-LABEL: test__popcnt
+// CIR: {{%.*}} = cir.popcount {{%.*}} : !u32i
+// LLVM-LABEL: test__popcnt
+// LLVM: {{%.*}} = call i32 @llvm.ctpop.i32(i32 {{%.*}})
+
+unsigned __int64 test__popcnt64(unsigned __int64 x) {
+ return __popcnt64(x);
+}
+// CIR-LABEL: test__popcnt64
+// CIR: {{%.*}} = cir.popcount {{%.*}} : !u64i
+// LLVM-LABEL: test__popcnt64
+// LLVM: {{%.*}} = call i64 @llvm.ctpop.i64(i64 {{%.*}})
diff --git a/clang/test/CIR/CodeGen/no-pie.c b/clang/test/CIR/CodeGen/no-pie.c
new file mode 100644
index 0000000000000..0639fd34c3633
--- /dev/null
+++ b/clang/test/CIR/CodeGen/no-pie.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fno-PIE -S -Xclang -emit-cir %s -o %t1.cir
+// RUN: FileCheck --input-file=%t1.cir %s -check-prefix=CIR
+// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fno-PIE -S -Xclang -emit-llvm %s -o %t1.ll
+// RUN: FileCheck --input-file=%t1.ll %s -check-prefix=LLVM
+
+extern int var;
+int get() {
+ return var;
+}
+// CIR: cir.global "private" external dso_local @var : !s32i {alignment = 4 : i64}
+// LLVM: @var = external dso_local global i32
diff --git a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
new file mode 100644
index 0000000000000..0dcf79f68c0f2
--- /dev/null
+++ b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
+
+void empty();
+
+void check_noproto_ptr() {
+ void (*fun)(void) = empty;
+}
+
+// CHECK: cir.func no_proto dso_local @check_noproto_ptr()
+// CHECK: [[ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>, ["fun", init] {alignment = 8 : i64}
+// CHECK: [[GGO:%.*]] = cir.get_global @empty : !cir.ptr<!cir.func<()>>
+// CHECK: cir.store{{.*}} [[GGO]], [[ALLOC]] : !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>
+// CHECK: cir.return
+
+void empty(void) {}
+
+void buz() {
+ void (*func)();
+ (*func)();
+}
+
+// CHECK: cir.func no_proto dso_local @buz()
+// CHECK: [[FNPTR_ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<(...)>>, !cir.ptr<!cir.ptr<!cir.func<(...)>>>, ["func"] {alignment = 8 : i64}
+// CHECK: [[FNPTR:%.*]] = cir.load deref{{.*}} [[FNPTR_ALLOC]] : !cir.ptr<!cir.ptr<!cir.func<(...)>>>, !cir.ptr<!cir.func<(...)>>
+// CHECK: [[CAST:%.*]] = cir.cast(bitcast, %1 : !cir.ptr<!cir.func<(...)>>), !cir.ptr<!cir.func<()>>
+// CHECK: cir.call [[CAST]]() : (!cir.ptr<!cir.func<()>>) -> ()
+// CHECK: cir.return
diff --git a/clang/test/CIR/CodeGen/no-proto-is-void.cpp b/clang/test/CIR/CodeGen/no-proto-is-void.cpp
new file mode 100644
index 0000000000000..ca917b7f90886
--- /dev/null
+++ b/clang/test/CIR/CodeGen/no-proto-is-void.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+// RUN: %clang_cc1 -x c -std=c2x -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+// Both CXX and C2X don't support no-prototype functions. They default to void.
+int noProto();
+// CHECK: cir.func dso_local @{{.*}}noProto{{.*}}() -> !s32i
+int test(int x) {
+ return noProto();
+ // CHECK {{.+}} = cir.call @{{.*}}noProto{{.*}}() : () -> !s32i
+}
+int noProto() { return 0; }
diff --git a/clang/test/CIR/CodeGen/null-arithmatic-expression.c b/clang/test/CIR/CodeGen/null-arithmatic-expression.c
new file mode 100644
index 0000000000000..a59a89e151f7c
--- /dev/null
+++ b/clang/test/CIR/CodeGen/null-arithmatic-expression.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-cir %s -o - | FileCheck %s
+
+#define NULL ((void *)0)
+
+char *foo() {
+ return (char*)NULL + 1;
+}
+
+// CHECK: cir.func no_proto dso_local @foo()
+// CHECK: [[CONST_1:%[0-9]+]] = cir.const #cir.int<1> : !s32i
+// CHECK: {{.*}} = cir.cast(int_to_ptr, [[CONST_1]] : !s32i)
+// CHECK: cir.return
diff --git a/clang/test/CIR/CodeGen/operators.cpp b/clang/test/CIR/CodeGen/operators.cpp
new file mode 100644
index 0000000000000..1d900188f1cee
--- /dev/null
+++ b/clang/test/CIR/CodeGen/operators.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+class __attribute__((__visibility__("default"))) exception_ptr
+{
+ void* __ptr_;
+public:
+ explicit operator bool() const noexcept {return __ptr_ != nullptr;}
+};
+
+// TODO: for now only check that this doesn't crash, in the future check operator
+// bool codegen.
+
+// CHECK: module
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/optimization-attr.cpp b/clang/test/CIR/CodeGen/optimization-attr.cpp
new file mode 100644
index 0000000000000..6af62bff6b35b
--- /dev/null
+++ b/clang/test/CIR/CodeGen/optimization-attr.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O0 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir --check-prefix=CHECK-O0 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O1 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir --check-prefix=CHECK-O1 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir --check-prefix=CHECK-O2 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O3 -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir --check-prefix=CHECK-O3 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Os -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir --check-prefix=CHECK-Os %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Oz -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir --check-prefix=CHECK-Oz %s
+
+void foo() {}
+
+// CHECK-O0: module
+// CHECK-O0-NOT: cir.opt_info
+
+// CHECK-O1: module
+// CHECK-O1: cir.opt_info = #cir.opt_info<level = 1, size = 0>
+
+// CHECK-O2: module
+// CHECK-O2: cir.opt_info = #cir.opt_info<level = 2, size = 0>
+
+// CHECK-O3: module
+// CHECK-O3: cir.opt_info = #cir.opt_info<level = 3, size = 0>
+
+// CHECK-Os: module
+// CHECK-Os: cir.opt_info = #cir.opt_info<level = 2, size = 1>
+
+// CHECK-Oz: module
+// CHECK-Oz: cir.opt_info = #cir.opt_info<level = 2, size = 2>
diff --git a/clang/test/CIR/CodeGen/pointer.cpp b/clang/test/CIR/CodeGen/pointer.cpp
new file mode 100644
index 0000000000000..bdf0e2103192b
--- /dev/null
+++ b/clang/test/CIR/CodeGen/pointer.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+// Global pointer should be zero initialized by default.
+int *ptr;
+// CHECK: cir.global external @ptr = #cir.ptr<null> : !cir.ptr<!s32i>
diff --git a/clang/test/CIR/CodeGen/return.cpp b/clang/test/CIR/CodeGen/return.cpp
new file mode 100644
index 0000000000000..e77dd5e1ac04a
--- /dev/null
+++ b/clang/test/CIR/CodeGen/return.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
+
+int &ret0(int &x) {
+ return x;
+}
+
+// CHECK: cir.func dso_local @_Z4ret0Ri
+// CHECK: %0 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["x", init, const] {alignment = 8 : i64}
+// CHECK: %1 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["__retval"] {alignment = 8 : i64}
+// CHECK: cir.store{{.*}} %arg0, %0 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
+// CHECK: %2 = cir.load %0 : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
+// CHECK: cir.store{{.*}} %2, %1 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
+// CHECK: %3 = cir.load %1 : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
+// CHECK: cir.return %3 : !cir.ptr<!s32i>
+
+int unreachable_after_return() {
+ return 0;
+ return 1;
+}
+
+// CHECK: cir.func dso_local @_Z24unreachable_after_returnv
+// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] {alignment = 4 : i64}
+// CHECK-NEXT: %1 = cir.const #cir.int<0> : !s32i
+// CHECK-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
+// CHECK-NEXT: cir.br ^bb1
+// CHECK-NEXT: ^bb1: // 2 preds: ^bb0, ^bb2
+// CHECK-NEXT: %2 = cir.load %0 : !cir.ptr<!s32i>, !s32i
+// CHECK-NEXT: cir.return %2 : !s32i
+// CHECK-NEXT: ^bb2: // no predecessors
+// CHECK-NEXT: %3 = cir.const #cir.int<1> : !s32i
+// CHECK-NEXT: cir.store{{.*}} %3, %0 : !s32i, !cir.ptr<!s32i>
+// CHECK-NEXT: cir.br ^bb1
+// CHECK-NEXT: }
diff --git a/clang/test/CIR/CodeGen/shift.cpp b/clang/test/CIR/CodeGen/shift.cpp
new file mode 100644
index 0000000000000..6f6a10d34ab08
--- /dev/null
+++ b/clang/test/CIR/CodeGen/shift.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+unsigned long s(int i, unsigned long x) {
+ return x << i;
+}
+
+// CHECK: cir.shift(left, %3 : !u64i, %4 : !s32i) -> !u64i
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/spelling-locations.cpp b/clang/test/CIR/CodeGen/spelling-locations.cpp
new file mode 100644
index 0000000000000..66c09c88a029c
--- /dev/null
+++ b/clang/test/CIR/CodeGen/spelling-locations.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+#define multiline_if_macro(c, t) \
+if (c) { \
+ return t; \
+}
+
+int testMacroLocations(void) {
+
+ // Expanded macros will use the location of the expansion site.
+ multiline_if_macro(1, 3);
+ // CHECK: cir.scope {
+ // CHECK: cir.if %{{.+}} {
+ // CHECK: cir.return %{{.+}} : !s32i loc(#loc[[#LOC:]])
+ // CHECK: } loc(#loc[[#LOC]])
+ // CHECK: } loc(#loc[[#LOC]])
+
+ // Regular if statements should use different locations.
+ if (1) {
+ return 3;
+ }
+ // CHECK: cir.scope {
+ // CHECK: cir.if %{{.+}} {
+ // CHECK: cir.return %{{.+}} : !s32i loc(#loc[[#LOC:]])
+ // CHECK-NOT: } loc(#loc[[#LOC]])
+ // CHECK-NOT: } loc(#loc[[#LOC]])
+
+ return 0;
+}
+
+void testIfStmtLocations(int f) {
+ if (f)
+ ;
+ else
+ ;
+
+ if (f)
+ ++f;
+ else
+ ;
+
+ if (f)
+ ;
+ else
+ --f;
+
+ if (f)
+ ++f;
+ else
+ --f;
+}
+
+// CHECK: cir.if %{{.+}} {
+// CHECK: } else {
+// CHECK: } loc(#loc[[#LOC1:]])
+
+// CHECK: cir.if %{{.+}} {
+// CHECK: %{{.+}} = cir.load
+// CHECK: %{{.+}} = cir.unary(inc
+// CHECK: cir.store
+// CHECK: } else {
+// CHECK: } loc(#loc[[#LOC2:]])
+
+// CHECK: cir.if %{{.+}} {
+// CHECK: } else {
+// CHECK: %{{.+}} = cir.load
+// CHECK: %{{.+}} = cir.unary(dec
+// CHECK: cir.store
+// CHECK: } loc(#loc[[#LOC3:]])
+
+// CHECK: cir.if %{{.+}} {
+// CHECK: %{{.+}} = cir.load
+// CHECK: %{{.+}} = cir.unary(inc
+// CHECK: cir.store
+// CHECK: } else {
+// CHECK: %{{.+}} = cir.load
+// CHECK: %{{.+}} = cir.unary(dec
+// CHECK: cir.store
+// CHECK: } loc(#loc[[#LOC4:]])
+
+// CHECK: #loc[[#LOC12:]] = loc({{.+}}:35:5)
+// CHECK: #loc[[#LOC11:]] = loc({{.+}}:33:5)
+
+// CHECK: #loc[[#LOC23:]] = loc({{.+}}:40:5)
+// CHECK: #loc[[#LOC21:]] = loc({{.+}}:38:5)
+// CHECK: #loc[[#LOC22:]] = loc({{.+}}:38:7)
+
+// CHECK: #loc[[#LOC33:]] = loc({{.+}}:45:7)
+// CHECK: #loc[[#LOC31:]] = loc({{.+}}:43:5)
+// CHECK: #loc[[#LOC32:]] = loc({{.+}}:45:5)
+
+// CHECK: #loc[[#LOC44:]] = loc({{.+}}:50:7)
+// CHECK: #loc[[#LOC41:]] = loc({{.+}}:48:5)
+// CHECK: #loc[[#LOC42:]] = loc({{.+}}:48:7)
+// CHECK: #loc[[#LOC43:]] = loc({{.+}}:50:5)
+
+// CHECK: #loc[[#LOC1]] = loc(fused[#loc[[#LOC11]], #loc[[#LOC12]]])
+// CHECK: #loc[[#LOC2]] = loc(fused[#loc[[#LOC21]], #loc[[#LOC22]], #loc[[#LOC23]]])
+// CHECK: #loc[[#LOC3]] = loc(fused[#loc[[#LOC31]], #loc[[#LOC32]], #loc[[#LOC33]]])
+// CHECK: #loc[[#LOC4]] = loc(fused[#loc[[#LOC41]], #loc[[#LOC42]], #loc[[#LOC43]], #loc[[#LOC44]]])
diff --git a/clang/test/CIR/CodeGen/std-array.cpp b/clang/test/CIR/CodeGen/std-array.cpp
new file mode 100644
index 0000000000000..cd9cc37a93367
--- /dev/null
+++ b/clang/test/CIR/CodeGen/std-array.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -I%S/../Inputs -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+#include "std-cxx.h"
+
+void t() {
+ std::array<unsigned char, 9> v = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+ (void)v.end();
+}
+
+// CHECK: ![[array:.*]] = !cir.record<struct "std::array<unsigned char, 9U>"
+
+// CHECK: cir.call @_ZNSt5arrayIhLj9EE3endEv
diff --git a/clang/test/CIR/CodeGen/stmt-expr.c b/clang/test/CIR/CodeGen/stmt-expr.c
new file mode 100644
index 0000000000000..cad7fc7eb1d6f
--- /dev/null
+++ b/clang/test/CIR/CodeGen/stmt-expr.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+// Yields void.
+void test1() { ({ }); }
+// CHECK: @test1
+// CHECK-NEXT: cir.return
+
+
+// Yields an out-of-scope scalar.
+void test2() { ({int x = 3; x; }); }
+// CHECK: @test2
+// CHECK: %[[#RETVAL:]] = cir.alloca !s32i, !cir.ptr<!s32i>
+// CHECK: cir.scope {
+// CHECK: %[[#VAR:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+// [...]
+// CHECK: %[[#TMP:]] = cir.load{{.*}} %[[#VAR]] : !cir.ptr<!s32i>, !s32i
+// CHECK: cir.store{{.*}} %[[#TMP]], %[[#RETVAL]] : !s32i, !cir.ptr<!s32i>
+// CHECK: }
+// CHECK: %{{.+}} = cir.load{{.*}} %[[#RETVAL]] : !cir.ptr<!s32i>, !s32i
+
+// Yields an aggregate.
+struct S { int x; };
+int test3() { return ({ struct S s = {1}; s; }).x; }
+// CHECK: @test3
+// CHECK: cir.scope {
+// CHECK: %[[#REF_TMP:]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["ref.tmp0"]
+// CHECK: cir.scope {
+// CHECK: %[[#VAR:]] = cir.alloca !rec_S, !cir.ptr<!rec_S>
+// [...]
+// CHECK: cir.copy %[[#VAR]] to %[[#REF_TMP]] : !cir.ptr<!rec_S>
+// CHECK: }
+// CHECK: %[[#RETADDR:]] = cir.get_member %[[#REF_TMP]][0] {name = "x"} : !cir.ptr<!rec_S> -> !cir.ptr<!s32i>
+// CHECK: %{{.+}} = cir.load{{.*}} %[[#RETADDR]] : !cir.ptr<!s32i>, !s32i
+
+// Expression is wrapped in an expression attribute (just ensure it does not crash).
+void test4(int x) { ({[[gsl::suppress("foo")]] x;}); }
+// CHECK: @test4
+
+// TODO(cir): Missing label support.
+// // Expression is wrapped in a label.
+// // void test5(int x) { x = ({ label: x; }); }
diff --git a/clang/test/CIR/CodeGen/store.c b/clang/test/CIR/CodeGen/store.c
new file mode 100644
index 0000000000000..7bf64773396ff
--- /dev/null
+++ b/clang/test/CIR/CodeGen/store.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+void foo(void) {
+ int a = 0;
+ a = 1;
+}
+
+// CHECK: cir.func dso_local @foo()
+// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init] {alignment = 4 : i64}
+// CHECK-NEXT: %1 = cir.const #cir.int<0> : !s32i
+// CHECK-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
+// CHECK-NEXT: %2 = cir.const #cir.int<1> : !s32i
+// CHECK-NEXT: cir.store{{.*}} %2, %0 : !s32i, !cir.ptr<!s32i>
+// CHECK-NEXT: cir.return
+// CHECK-NEXT: }
+
+typedef int (*fn_t)();
+int get42() { return 42; }
+
+void storeNoArgsFn() {
+ fn_t f = get42;
+}
+
+// CHECK: cir.func {{.*@storeNoArgsFn}}
+// CHECK: %0 = cir.alloca
+// CHECK: %1 = cir.get_global @get42 : !cir.ptr<!cir.func<() -> !s32i>>
+// CHECK: %2 = cir.cast(bitcast, %1 : !cir.ptr<!cir.func<() -> !s32i>>), !cir.ptr<!cir.func<(...) -> !s32i>>
+// CHECK: cir.store{{.*}} %2, %0 : !cir.ptr<!cir.func<(...) -> !s32i>>, !cir.ptr<!cir.ptr<!cir.func<(...) -> !s32i>>>
diff --git a/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp b/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
new file mode 100644
index 0000000000000..5b72b3a02b9b5
--- /dev/null
+++ b/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
@@ -0,0 +1,49 @@
+// 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: _Z23unreachable_after_breaki
+void unreachable_after_break(int a) {
+ switch(a) {
+ case 0:
+ break;
+ break;
+ int x = 1;
+ }
+ // cir.switch
+ // cir.case(equal, [#cir.int<0> : !s32i]) {
+ // cir.break
+ // ^bb{{.*}}: // no predecessors
+ // cir.break
+ // ^bb{{.*}}: // no predecessors
+ // %[[CONST:.*]] = cir.const #cir.int<1> : !s32i
+ // cir.store align(4) {{.*}}, %[[CONST]]
+ // cir.yield
+}
+
+// CHECK: _Z24unreachable_after_returni
+int unreachable_after_return(int a) {
+ switch (a) {
+ case 0:
+ return 0;
+ return 1;
+ int x = 3;
+ }
+ return 2;
+ // cir.switch
+ // cir.case(equal, [#cir.int<0> : !s32i]) {
+ // %[[CONST_ZERO:.*]] = cir.const #cir.int<0> : !s32i
+ // cir.store {{.*}}, %[[CONST_ZERO]]
+ // cir.br ^bb1
+ // ^bb1: // 2 preds: ^bb0, ^bb2
+ // cir.load
+ // cir.return
+ // ^bb2: // no predecessors
+ // %[[CONST_ONE:.*]] = cir.const #cir.int<1> : !s32i
+ // cir.store %[[CONST_ONE]]
+ // cir.br ^bb1
+ // ^bb3: // no predecessors
+ // %[[CONST_THREE:.*]] = cir.const #cir.int<3> : !s32i
+ // cir.store align(4) %[[CONST_THREE]]
+ // cir.yield
+ // }
+}
diff --git a/clang/test/CIR/CodeGen/trap.cpp b/clang/test/CIR/CodeGen/trap.cpp
new file mode 100644
index 0000000000000..83e9be7230d2b
--- /dev/null
+++ b/clang/test/CIR/CodeGen/trap.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+void foo();
+
+void basic() {
+ foo();
+ __builtin_trap();
+}
+
+// CHECK: cir.func dso_local @_Z5basicv()
+// CHECK-NEXT: cir.call @_Z3foov() : () -> ()
+// CHECK-NEXT: cir.trap
+// CHECK-NEXT: }
+
+void code_after_unreachable() {
+ foo();
+ __builtin_trap();
+ foo();
+}
+
+// CHECK: cir.func dso_local @_Z22code_after_unreachablev()
+// CHECK-NEXT: cir.call @_Z3foov() : () -> ()
+// CHECK-NEXT: cir.trap
+// CHECK-NEXT: ^bb1:
+// CHECK-NEXT: cir.call @_Z3foov() : () -> ()
+// CHECK-NEXT: cir.return
+// CHECK-NEXT: }
diff --git a/clang/test/CIR/CodeGen/types-IEEE-quad.c b/clang/test/CIR/CodeGen/types-IEEE-quad.c
new file mode 100644
index 0000000000000..c56b3e7ca6d2b
--- /dev/null
+++ b/clang/test/CIR/CodeGen/types-IEEE-quad.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir --check-prefix=CIR %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
+
+long double i = 0;
+long double t2(long double i2) {
+ return i2 + i ;
+}
+
+// CIR: cir.global external @i = #cir.fp<0.000000e+00> : !cir.long_double<!cir.f128> {alignment = 16 : i64} loc({{.*}})
+// CIR-LABEL: cir.func dso_local @t2(%arg0: !cir.long_double<!cir.f128> loc({{.*}})) -> !cir.long_double<!cir.f128>
+// CIR-NEXT: %[[#I2:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["i2", init] {alignment = 16 : i64}
+// CIR-NEXT: %[[#RETVAL:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["__retval"] {alignment = 16 : i64}
+// CIR-NEXT: cir.store %arg0, %[[#I2]] : !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>
+// CIR-NEXT: %[[#I2_LOAD:]] = cir.load{{.*}} %[[#I2]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
+// CIR-NEXT: %[[#I:]] = cir.get_global @i : !cir.ptr<!cir.long_double<!cir.f128>>
+// CIR-NEXT: %[[#I_LOAD:]] = cir.load{{.*}} %[[#I]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
+// CIR-NEXT: %[[#ADD:]] = cir.binop(add, %[[#I2_LOAD]], %[[#I_LOAD]]) : !cir.long_double<!cir.f128>
+// CIR-NEXT: cir.store %[[#ADD]], %[[#RETVAL]] : !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>
+// CIR-NEXT: %[[#RETVAL_LOAD:]] = cir.load{{.*}} %[[#RETVAL]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
+// CIR-NEXT: cir.return %[[#RETVAL_LOAD]] : !cir.long_double<!cir.f128>
+
+//LLVM: @i = global fp128 0xL00000000000000000000000000000000, align 16
+//LLVM-LABEL: define dso_local fp128 @t2(fp128 noundef %i2)
+//LLVM-NEXT : entry:
+//LLVM-NEXT : %[[#I2_ADDR:]]= alloca fp128, align 16
+//LLVM-NEXT : store fp128 %i2, ptr %[[#I2_ADDR]], align 16
+//LLVM-NEXT : %[[#I2_LOAD:]] = load fp128, ptr %[[#I2_ADDR]], align 16
+//LLVM-NEXT : %[[#I_LOAD:]] = load fp128, ptr @i, align 16
+//LLVM-NEXT : %[[#RETVAL:]] = fadd fp128 %[[#I2_LOAD]], %[[#I_LOAD]]
+//LLVM-NEXT : ret fp128 %[[#RETVAL]]
diff --git a/clang/test/CIR/CodeGen/types-nullptr.cpp b/clang/test/CIR/CodeGen/types-nullptr.cpp
new file mode 100644
index 0000000000000..a598a1a724f6e
--- /dev/null
+++ b/clang/test/CIR/CodeGen/types-nullptr.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+typedef decltype(nullptr) nullptr_t;
+void f() { nullptr_t t = nullptr; }
+
+// CHECK: %0 = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>
+// CHECK: %1 = cir.const #cir.ptr<null> : !cir.ptr<!void>
+// CHECK: cir.store{{.*}} %1, %0 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>
diff --git a/clang/test/CIR/CodeGen/types.c b/clang/test/CIR/CodeGen/types.c
new file mode 100644
index 0000000000000..d409514a81d56
--- /dev/null
+++ b/clang/test/CIR/CodeGen/types.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cpp.cir
+// RUN: FileCheck --input-file=%t.cpp.cir --check-prefix=CHECK-CPP %s
+
+int t0(int i) { return i; }
+unsigned int t1(unsigned int i) { return i; }
+
+char t2(char i) { return i; }
+unsigned char t3(unsigned char i) { return i; }
+
+short t4(short i) { return i; }
+unsigned short t5(unsigned short i) { return i; }
+
+float t6(float i) { return i; }
+double t7(double i) { return i; }
+long double t10(long double i) { return i; }
+
+void t8(void) {}
+
+#ifdef __cplusplus
+bool t9(bool b) { return b; }
+#endif
+
+// CHECK: cir.func dso_local @t0(%arg0: !s32i loc({{.*}})) -> !s32i
+// CHECK: cir.func dso_local @t1(%arg0: !u32i loc({{.*}})) -> !u32i
+// CHECK: cir.func dso_local @t2(%arg0: !s8i loc({{.*}})) -> !s8i
+// CHECK: cir.func dso_local @t3(%arg0: !u8i loc({{.*}})) -> !u8i
+// CHECK: cir.func dso_local @t4(%arg0: !s16i loc({{.*}})) -> !s16i
+// CHECK: cir.func dso_local @t5(%arg0: !u16i loc({{.*}})) -> !u16i
+// CHECK: cir.func dso_local @t6(%arg0: !cir.float loc({{.*}})) -> !cir.float
+// CHECK: cir.func dso_local @t7(%arg0: !cir.double loc({{.*}})) -> !cir.double
+// CHECK: cir.func dso_local @t10(%arg0: !cir.long_double<!cir.f80> loc({{.*}})) -> !cir.long_double<!cir.f80>
+// CHECK: cir.func dso_local @t8()
+
+// CHECK-CPP: cir.func dso_local @_Z2t0i(%arg0: !s32i loc({{.*}})) -> !s32i
+// CHECK-CPP: cir.func dso_local @_Z2t1j(%arg0: !u32i loc({{.*}})) -> !u32i
+// CHECK-CPP: cir.func dso_local @_Z2t2c(%arg0: !s8i loc({{.*}})) -> !s8i
+// CHECK-CPP: cir.func dso_local @_Z2t3h(%arg0: !u8i loc({{.*}})) -> !u8i
+// CHECK-CPP: cir.func dso_local @_Z2t4s(%arg0: !s16i loc({{.*}})) -> !s16i
+// CHECK-CPP: cir.func dso_local @_Z2t5t(%arg0: !u16i loc({{.*}})) -> !u16i
+// CHECK-CPP: cir.func dso_local @_Z2t6f(%arg0: !cir.float loc({{.*}})) -> !cir.float
+// CHECK-CPP: cir.func dso_local @_Z2t7d(%arg0: !cir.double loc({{.*}})) -> !cir.double
+// CHECK-CPP: cir.func dso_local @{{.+}}t10{{.+}}(%arg0: !cir.long_double<!cir.f80> loc({{.*}})) -> !cir.long_double<!cir.f80>
+// CHECK-CPP: cir.func dso_local @_Z2t8v()
+// CHECK-CPP: cir.func dso_local @_Z2t9b(%arg0: !cir.bool loc({{.*}})) -> !cir.bool
diff --git a/clang/test/CIR/CodeGen/unary.c b/clang/test/CIR/CodeGen/unary.c
new file mode 100644
index 0000000000000..ebcae89e2bdb0
--- /dev/null
+++ b/clang/test/CIR/CodeGen/unary.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+int valueNegationInt(int i) {
+// CHECK: cir.func dso_local @valueNegationInt(
+ return !i;
+ // CHECK: %[[#INT:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s32i>, !s32i
+ // CHECK: %[[#INT_TO_BOOL:]] = cir.cast(int_to_bool, %[[#INT]] : !s32i), !cir.bool
+ // CHECK: = cir.unary(not, %[[#INT_TO_BOOL]]) : !cir.bool, !cir.bool
+}
+
+short valueNegationShort(short s) {
+// CHECK: cir.func dso_local @valueNegationShort(
+ return !s;
+ // CHECK: %[[#SHORT:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s16i>, !s16i
+ // CHECK: %[[#SHORT_TO_BOOL:]] = cir.cast(int_to_bool, %[[#SHORT]] : !s16i), !cir.bool
+ // CHECK: = cir.unary(not, %[[#SHORT_TO_BOOL]]) : !cir.bool, !cir.bool
+}
+
+long valueNegationLong(long l) {
+// CHECK: cir.func dso_local @valueNegationLong(
+ return !l;
+ // CHECK: %[[#LONG:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s64i>, !s64i
+ // CHECK: %[[#LONG_TO_BOOL:]] = cir.cast(int_to_bool, %[[#LONG]] : !s64i), !cir.bool
+ // CHECK: = cir.unary(not, %[[#LONG_TO_BOOL]]) : !cir.bool, !cir.bool
+}
+
+float valueNegationFloat(float f) {
+// CHECK: cir.func dso_local @valueNegationFloat(
+ return !f;
+ // CHECK: %[[#FLOAT:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!cir.float>, !cir.float
+ // CHECK: %[[#FLOAT_TO_BOOL:]] = cir.cast(float_to_bool, %[[#FLOAT]] : !cir.float), !cir.bool
+ // CHECK: %[[#FLOAT_NOT:]] = cir.unary(not, %[[#FLOAT_TO_BOOL]]) : !cir.bool, !cir.bool
+ // CHECK: = cir.cast(bool_to_int, %[[#FLOAT_NOT]] : !cir.bool), !s32i
+}
+
+double valueNegationDouble(double d) {
+// CHECK: cir.func dso_local @valueNegationDouble(
+ return !d;
+ // CHECK: %[[#DOUBLE:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!cir.double>, !cir.double
+ // CHECK: %[[#DOUBLE_TO_BOOL:]] = cir.cast(float_to_bool, %[[#DOUBLE]] : !cir.double), !cir.bool
+ // CHECK: %[[#DOUBLE_NOT:]] = cir.unary(not, %[[#DOUBLE_TO_BOOL]]) : !cir.bool, !cir.bool
+ // CHECK: = cir.cast(bool_to_int, %[[#DOUBLE_NOT]] : !cir.bool), !s32i
+}
diff --git a/clang/test/CIR/CodeGen/unreachable.cpp b/clang/test/CIR/CodeGen/unreachable.cpp
new file mode 100644
index 0000000000000..07c4fc434e4ee
--- /dev/null
+++ b/clang/test/CIR/CodeGen/unreachable.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --input-file=%t.cir %s
+
+void foo();
+
+void basic() {
+ foo();
+ __builtin_unreachable();
+}
+
+// CHECK: cir.func dso_local @_Z5basicv()
+// CHECK-NEXT: cir.call @_Z3foov() : () -> ()
+// CHECK-NEXT: cir.unreachable
+// CHECK-NEXT: }
+
+void code_after_unreachable() {
+ foo();
+ __builtin_unreachable();
+ foo();
+}
+
+// CHECK: cir.func dso_local @_Z22code_after_unreachablev()
+// CHECK: cir.call @_Z3foov() : () -> ()
+// CHECK: cir.unreachable
+// CHECK: ^{{.+}}:
+// CHECK: cir.call @_Z3foov() : () -> ()
+// CHECK: cir.return
+// CHECK: }
diff --git a/clang/test/CIR/Lowering/bitfieils.c b/clang/test/CIR/Lowering/bitfieils.c
new file mode 100644
index 0000000000000..19de2ab194d41
--- /dev/null
+++ b/clang/test/CIR/Lowering/bitfieils.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+typedef struct {
+ int a : 4;
+} B;
+
+// LLVM: define dso_local void @set_signed
+// LLVM: [[TMP0:%.*]] = load ptr
+// LLVM: [[TMP1:%.*]] = getelementptr %struct.B, ptr [[TMP0]], i32 0, i32 0
+// LLVM: [[TMP2:%.*]] = load i8, ptr [[TMP1]]
+// LLVM: [[TMP3:%.*]] = and i8 [[TMP2]], -16
+// LLVM: [[TMP4:%.*]] = or i8 [[TMP3]], 14
+// LLVM: store i8 [[TMP4]], ptr [[TMP1]]
+void set_signed(B* b) {
+ b->a = -2;
+}
+
+// LLVM: define dso_local i32 @get_signed
+// LLVM: [[TMP0:%.*]] = alloca i32
+// LLVM: [[TMP1:%.*]] = load ptr
+// LLVM: [[TMP2:%.*]] = getelementptr %struct.B, ptr [[TMP1]], i32 0, i32 0
+// LLVM: [[TMP3:%.*]] = load i8, ptr [[TMP2]]
+// LLVM: [[TMP4:%.*]] = shl i8 [[TMP3]], 4
+// LLVM: [[TMP5:%.*]] = ashr i8 [[TMP4]], 4
+// LLVM: [[TMP6:%.*]] = sext i8 [[TMP5]] to i32
+// LLVM: store i32 [[TMP6]], ptr [[TMP0]]
+// LLVM: [[TMP7:%.*]] = load i32, ptr [[TMP0]]
+// LLVM: ret i32 [[TMP7]]
+int get_signed(B* b) {
+ return b->a;
+}
diff --git a/clang/test/CIR/Lowering/global-ptr.c b/clang/test/CIR/Lowering/global-ptr.c
new file mode 100644
index 0000000000000..a283ba0389524
--- /dev/null
+++ b/clang/test/CIR/Lowering/global-ptr.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+// LLVM: %struct.S1 = type { [3200 x double], [3200 x double] }
+// LLVM: %struct.S2 = type { [10 x ptr] }
+// LLVM: %struct.S3 = type { [2000 x i32], [2000 x i32], [2000 x i32] }
+// LLVM: %struct.S4 = type { i32, i32, i32 }
+// LLVM: %union.U1 = type { [2000 x i32] }
+
+// Note: GEP emitted by cir might not be the same as LLVM, due to constant folding.
+// LLVM: @s1 = global %struct.S1 zeroinitializer, align 8
+// LLVM: @b1 = global ptr getelementptr inbounds nuw (i8, ptr @s1, i64 25600), align 8
+// LLVM: @s2 = global %struct.S2 zeroinitializer, align 8
+// LLVM: @b2 = global ptr @s2, align 8
+// LLVM: @s3 = global %struct.S3 zeroinitializer, align 4
+// LLVM: @b3 = global ptr getelementptr inbounds nuw (i8, ptr @s3, i64 16000), align 8
+// LLVM: @s4 = global %struct.S4 zeroinitializer, align 4
+// LLVM: @b4 = global ptr getelementptr inbounds nuw (i8, ptr @s4, i64 8), align 8
+// LLVM: @u1 = global %union.U1 zeroinitializer, align 4
+// LLVM: @b5 = global ptr @u1, align 8
+
+struct S1 {
+ double a[3200];
+ double b[3200];
+} s1;
+
+double *b1 = s1.b;
+
+struct S2 {
+ double* a[10];
+} s2;
+
+double **b2 = s2.a;
+
+struct S3 {
+ int a[2000];
+ int b[2000];
+ int c[2000];
+} s3;
+
+double *b3 = s3.c;
+
+struct S4 {
+ int a, b, c;
+} s4;
+
+int* b4 = &s4.c;
+
+union U1 {
+ int a[2000];
+ int b[2000];
+ int c[2000];
+} u1;
+
+double *b5 = u1.a;
diff --git a/clang/test/CIR/Lowering/nested-switch.cpp b/clang/test/CIR/Lowering/nested-switch.cpp
new file mode 100644
index 0000000000000..5f6961a84018f
--- /dev/null
+++ b/clang/test/CIR/Lowering/nested-switch.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s
+
+int nested_switch(int a) {
+ switch (int b = 1; a) {
+ case 0:
+ b = b + 1;
+ case 1:
+ return b;
+ case 2: {
+ b = b + 1;
+ if (a > 1000) {
+ case 9:
+ b += a;
+ }
+ if (a > 500) {
+ case 7:
+ return a + b;
+ }
+ break;
+ }
+ }
+
+ return 0;
+}
+
+// CHECK: define {{.*}}@_Z13nested_switchi(
+// CHECK: switch i32 %6, label %[[DEFAULT_BB:[0-9]+]] [
+// CHECK: i32 0, label %[[ZERO_BB:[0-9]+]]
+// CHECK: i32 1, label %[[ONE_BB:[0-9]+]]
+// CHECK: i32 2, label %[[TWO_BB:[0-9]+]]
+// CHECK: i32 9, label %[[NINE_BB:[0-9]+]]
+// CHECK: i32 7, label %[[SEVEN_BB:[0-9]+]]
+// CHECK: ]
+//
+// CHECK: [[ZERO_BB]]:
+// CHECK: add {{.*}}, 1
+// CHECK: br label %[[ONE_BB]]
+//
+// CHECK: [[ONE_BB]]:
+// CHECK: ret
+//
+// CHECK: [[TWO_BB]]:
+// CHECK: add {{.*}}, 1
+// CHECK: br label %[[IF_BB:[0-9]+]]
+//
+// CHECK: [[IF_BB]]:
+// CHECK: %[[CMP:.+]] = icmp sgt i32 %{{.*}}, 1000
+// CHECK: br i1 %[[CMP]], label %[[IF_TRUE_BB:[0-9]+]], label %[[IF_FALSE_BB:[0-9]+]]
+//
+// CHECK: [[IF_TRUE_BB]]:
+// CHECK: br label %[[NINE_BB]]
+//
+// CHECK: [[NINE_BB]]:
+// CHECK: %[[A_VALUE:.+]] = load i32
+// CHECK: %[[B_VALUE:.+]] = load i32
+// CHECK: add nsw i32 %[[B_VALUE]], %[[A_VALUE]]
+//
+// CHECK: %[[CMP2:.+]] = icmp sgt i32 %{{.*}}, 500
+// CHECK: br i1 %[[CMP2]], label %[[IF2_TRUE_BB:[0-9]+]], label %[[IF2_FALSE_BB:[0-9]+]]
+//
+// CHECK: [[IF2_TRUE_BB]]:
+// CHECK: br label %[[SEVEN_BB]]
+//
+// CHECK: [[SEVEN_BB]]:
+// CHECK: ret
+//
+// CHECK: [[DEFAULT_BB]]:
+// CHECK: ret
diff --git a/clang/test/CIR/Lowering/str.c b/clang/test/CIR/Lowering/str.c
new file mode 100644
index 0000000000000..cc393daee884f
--- /dev/null
+++ b/clang/test/CIR/Lowering/str.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+void f(char *fmt, ...);
+void test() {
+ f("test\0");
+}
+
+// LLVM: @.str = {{.*}}[6 x i8] c"test\00\00"
diff --git a/clang/test/CIR/Lowering/switch-while.c b/clang/test/CIR/Lowering/switch-while.c
new file mode 100644
index 0000000000000..9123d55329607
--- /dev/null
+++ b/clang/test/CIR/Lowering/switch-while.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s
+void func100();
+int f(int a, int cond) {
+ int b = 1;
+ switch (a)
+ while (1) {
+ b++;
+
+ default:
+ if (cond)
+ return a;
+
+ a = a + b;
+
+ case 2:
+ a++;
+
+ case 3:
+ continue;
+
+ case 5:
+ break;
+
+ case 100:
+ func100();
+ }
+
+ return a;
+}
+
+// CHECK: switch i32 %[[A:.+]], label %[[DEFAULT_BB:.+]] [
+// CHECK: i32 2, label %[[TWO_BB:.+]]
+// CHECK: i32 3, label %[[THREE_BB:.+]]
+// CHECK: i32 5, label %[[FIVE_BB:.+]]
+// CHECK: i32 100, label %[[HUNDRED_BB:.+]]
+// CHECK: ]
+//
+// CHECK: [[UNREACHABLE_BB:.+]]: {{.*}}; No predecessors!
+//
+// CHECK: [[LOOP_ENTRY:.+]]:
+// CHECK: br label %[[LOOP_HEADER:.+]]
+//
+// CHECK: [[LOOP_HEADER]]:
+// CHECK: add nsw i32 %{{.*}}, 1
+// CHECK: br label %[[DEFAULT_BB:.+]]
+//
+// CHECK: [[DEFAULT_BB]]:
+// CHECK: br label %[[IF_BB:.+]]
+//
+// CHECK: [[IF_BB]]:
+// CHECK: %[[CMP:.+]] = icmp ne i32 %[[COND:.+]], 0
+// CHECK: br i1 %[[CMP]], label %[[IF_TRUE_BB:.+]], label %[[IF_FALSE_BB:.+]]
+//
+// CHECK: [[IF_TRUE_BB]]:
+// CHECK: ret
+//
+// CHECK: [[IF_FALSE_BB]]:
+// CHECK: %[[V1:.+]] = load i32
+// CHECK: %[[V2:.+]] = load i32
+// CHECK: add nsw i32 %[[V1]], %[[V2]]
+//
+// CHECK: [[TWO_BB]]:
+// CHECK: add nsw i32 %{{.*}}, 1
+// CHECK: br label %[[FALLTHOUGH_BB:.+]]
+//
+// CHECK: [[FALLTHOUGH_BB]]:
+// CHECK: br label %[[LOOP_HEADER]]
+//
+// CHECK: [[FIVE_BB]]:
+// CHECK: br label %[[LOOP_EXIT_BB:.+]]
+//
+// CHECK: [[HUNDRED_BB]]:
+// CHECK: call {{.*}}@func100()
+// CHECK: br label %[[CONTINUE_BB:.+]]
+//
+// CHECK: [[CONTINUE_BB]]:
+// CHECK: br label %[[LOOP_HEADER]]
+//
+// CHECK: [[LOOP_EXIT_BB]]:
+// CHECK: br label %[[RET_BB:.+]]
+//
+// CHECK: [[RET_BB]]:
+// CHECK: ret
diff --git a/clang/test/CIR/hello.c b/clang/test/CIR/hello.c
new file mode 100644
index 0000000000000..077f5c6ac908f
--- /dev/null
+++ b/clang/test/CIR/hello.c
@@ -0,0 +1,5 @@
+// Smoke test for ClangIR code generation
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
+
+void foo() {}
+// CHECK: cir.func no_proto dso_local @foo
diff --git a/clang/test/CIR/test.c b/clang/test/CIR/test.c
new file mode 100644
index 0000000000000..5c1031cccc41a
--- /dev/null
+++ b/clang/test/CIR/test.c
@@ -0,0 +1 @@
+// RUN: true
>From 57dbc230e896b187b42d13b628ab130a2d9ba509 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 09:29:58 +0300
Subject: [PATCH 02/57] Update clang/test/CIR/CodeGen/binassign.cpp
Co-authored-by: Andy Kaylor <akaylor at nvidia.com>
---
clang/test/CIR/CodeGen/binassign.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/binassign.cpp b/clang/test/CIR/CodeGen/binassign.cpp
index 934742d13404a..567c259dfc6b9 100644
--- a/clang/test/CIR/CodeGen/binassign.cpp
+++ b/clang/test/CIR/CodeGen/binassign.cpp
@@ -16,7 +16,7 @@ int foo(int a, int b) {
return x;
}
-// CHECK: [[Value:%[0-9]+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
+// CHECK: [[Value:%[0-9]+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
// CHECK: = cir.binop(mul,
// CHECK: = cir.load {{.*}}[[Value]]
// CHECK: = cir.binop(mul,
>From 813e014bc0f60527f7b7d93753bd0fbc4670534f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 09:30:32 +0300
Subject: [PATCH 03/57] Update clang/test/CIR/CodeGen/binassign.cpp
Co-authored-by: Andy Kaylor <akaylor at nvidia.com>
---
clang/test/CIR/CodeGen/binassign.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/binassign.cpp b/clang/test/CIR/CodeGen/binassign.cpp
index 567c259dfc6b9..ab5dab7797c6e 100644
--- a/clang/test/CIR/CodeGen/binassign.cpp
+++ b/clang/test/CIR/CodeGen/binassign.cpp
@@ -25,7 +25,7 @@ int foo(int a, int b) {
// CHECK: cir.binop(div,
// CHECK: cir.store{{.*}} {{.*}}[[Value]]
// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(rem, {{.*}} loc([[SourceLocation:#loc[0-9]+]])
+// CHECK: = cir.binop(rem,
// CHECK: cir.store{{.*}} {{.*}}[[Value]]
// CHECK: = cir.load {{.*}}[[Value]]
// CHECK: = cir.binop(add,
>From cdceaa317a90602b7da28642184df5dd6f946edc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:20:19 +0300
Subject: [PATCH 04/57] Delete clang/test/CIR/CodeGen/OpenMP/taskwait.cpp
---
clang/test/CIR/CodeGen/OpenMP/taskwait.cpp | 9 ---------
1 file changed, 9 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/OpenMP/taskwait.cpp
diff --git a/clang/test/CIR/CodeGen/OpenMP/taskwait.cpp b/clang/test/CIR/CodeGen/OpenMP/taskwait.cpp
deleted file mode 100644
index 3b2059a8b9655..0000000000000
--- a/clang/test/CIR/CodeGen/OpenMP/taskwait.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// TODO: fix crash in emitTaskWaitCall
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fopenmp-enable-irbuilder -fopenmp -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-// CHECK: cir.func
-void omp_taskwait_1(){
-// CHECK-DISABLE: omp.taskwait
-// #pragma omp taskwait
-}
>From 7591d38f707a34756ccf7c5707b10c5d84f8b51d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:20:46 +0300
Subject: [PATCH 05/57] Delete clang/test/CIR/CodeGen/StringExample.cpp
---
clang/test/CIR/CodeGen/StringExample.cpp | 34 ------------------------
1 file changed, 34 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/StringExample.cpp
diff --git a/clang/test/CIR/CodeGen/StringExample.cpp b/clang/test/CIR/CodeGen/StringExample.cpp
deleted file mode 100644
index a2c0ef374f1ca..0000000000000
--- a/clang/test/CIR/CodeGen/StringExample.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: true
-
-int strlen(char const *);
-void puts(char const *);
-
-struct String {
- long size;
- long capacity;
- char *storage;
-
- String() : size{0}, capacity{0}, storage{nullptr} {}
- String(char const *s) : size{strlen(s)}, capacity{size},
- storage{new char[capacity]} {}
-};
-
-struct StringView {
- long size;
- char *storage;
-
- StringView(const String &s) : size{s.size}, storage{s.storage} {}
- StringView() : size{0}, storage{nullptr} {}
-};
-
-int main() {
- StringView sv;
- {
- String s = "Hi";
- sv = s;
-
- puts(sv.storage);
- }
-
- puts(sv.storage);
-}
>From bca917d010f8f74224f9437240bf3bb463416b60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:22:17 +0300
Subject: [PATCH 06/57] Update binassign.cpp
---
clang/test/CIR/CodeGen/binassign.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/binassign.cpp b/clang/test/CIR/CodeGen/binassign.cpp
index ab5dab7797c6e..fc60da8687f56 100644
--- a/clang/test/CIR/CodeGen/binassign.cpp
+++ b/clang/test/CIR/CodeGen/binassign.cpp
@@ -61,7 +61,7 @@ void exec() {
}
// CHECK: cir.func dso_local @_Z4execv()
-// CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["r"] {alignment = 4 : i64}
+// CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["r"]
// CHECK: cir.scope {
// CHECK: %1 = cir.call @_Z5gettyv() : () -> !u32i
// CHECK: cir.store{{.*}} %1, %0 : !u32i, !cir.ptr<!u32i>
>From 39ce12f168b5bfc9b6b11591e88dc89511a65df5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:23:46 +0300
Subject: [PATCH 07/57] Update binassign.cpp
---
clang/test/CIR/CodeGen/binassign.cpp | 4 ----
1 file changed, 4 deletions(-)
diff --git a/clang/test/CIR/CodeGen/binassign.cpp b/clang/test/CIR/CodeGen/binassign.cpp
index fc60da8687f56..c33cdfd228871 100644
--- a/clang/test/CIR/CodeGen/binassign.cpp
+++ b/clang/test/CIR/CodeGen/binassign.cpp
@@ -69,7 +69,3 @@ void exec() {
// CHECK: %3 = cir.const #cir.int<0> : !s32i
// CHECK: %4 = cir.cmp(lt, %2, %3) : !s32i, !cir.bool
// CHECK: cir.if %4 {
-
-// CHECK: [[SourceLocationB:#loc[0-9]+]] = loc("{{.*}}binassign.cpp":8:8)
-// CHECK: [[SourceLocationA:#loc[0-9]+]] = loc("{{.*}}binassign.cpp":8:3)
-// CHECK: [[SourceLocation]] = loc(fused[[[SourceLocationA]], [[SourceLocationB]]])
>From 0ffceff70b7c919b7a798e0c451a8cf9b6a37024 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:25:46 +0300
Subject: [PATCH 08/57] Delete clang/test/CIR/CodeGen/bswap.cpp
---
clang/test/CIR/CodeGen/bswap.cpp | 30 ------------------------------
1 file changed, 30 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/bswap.cpp
diff --git a/clang/test/CIR/CodeGen/bswap.cpp b/clang/test/CIR/CodeGen/bswap.cpp
deleted file mode 100644
index 3473b64ac7228..0000000000000
--- a/clang/test/CIR/CodeGen/bswap.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-using u16 = unsigned short;
-using u32 = unsigned int;
-using u64 = unsigned long long;
-
-u16 bswap_u16(u16 x) {
- return __builtin_bswap16(x);
-}
-
-// CHECK: cir.func dso_local @_Z9bswap_u16t
-// CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u16i
-// CHECK: }
-
-u32 bswap_u32(u32 x) {
- return __builtin_bswap32(x);
-}
-
-// CHECK: cir.func dso_local @_Z9bswap_u32j
-// CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u32i
-// CHECK: }
-
-u64 bswap_u64(u64 x) {
- return __builtin_bswap64(x);
-}
-
-// CHECK: cir.func dso_local @_Z9bswap_u64y
-// CHECK: %{{.+}} = cir.byte_swap %{{.+}} : !u64i
-// CHECK: }
>From c977bca98f69ad64b5ddf3ae6b656a87b6cb3c8a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:27:49 +0300
Subject: [PATCH 09/57] Update if-constexpr.cpp
---
clang/test/CIR/CodeGen/if-constexpr.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/if-constexpr.cpp b/clang/test/CIR/CodeGen/if-constexpr.cpp
index dd13591be17f4..4ce44bfa6cba0 100644
--- a/clang/test/CIR/CodeGen/if-constexpr.cpp
+++ b/clang/test/CIR/CodeGen/if-constexpr.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -std=c++20 -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 if0() {
int x = 0;
>From 03312d2edd6182209ea0434b155cfab25396cdc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:32:24 +0300
Subject: [PATCH 10/57] Update if-constexpr.cpp
---
clang/test/CIR/CodeGen/if-constexpr.cpp | 110 ++++++++++++------------
1 file changed, 56 insertions(+), 54 deletions(-)
diff --git a/clang/test/CIR/CodeGen/if-constexpr.cpp b/clang/test/CIR/CodeGen/if-constexpr.cpp
index 4ce44bfa6cba0..70a08706be6ab 100644
--- a/clang/test/CIR/CodeGen/if-constexpr.cpp
+++ b/clang/test/CIR/CodeGen/if-constexpr.cpp
@@ -3,90 +3,92 @@
void if0() {
int x = 0;
+
if constexpr (0 == 0) {
- // Declare a variable with same name to be sure we handle the
- // scopes correctly
+ // CIR: cir.scope {
+ // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+ // CIR-NEXT: %3 = cir.const #cir.int<2> : !s32i
+ // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: }
int x = 2;
} else {
int x = 3;
}
+
if constexpr (0 == 1) {
int x = 4;
} else {
+ // CIR: cir.scope {
+ // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+ // CIR-NEXT: %3 = cir.const #cir.int<5> : !s32i
+ // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: }
int x = 5;
}
+
if constexpr (int x = 7; 8 == 8) {
+ // CIR: cir.scope {
+ // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+ // CIR-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init]
+ // CIR-NEXT: %4 = cir.const #cir.int<7> : !s32i
+ // CIR-NEXT: cir.store %4, %2 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: %5 = cir.load %2 : !cir.ptr<!s32i>, !s32i
+ // CIR-NEXT: cir.store %5, %3 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: }
int y = x;
} else {
int y = 2*x;
}
+
if constexpr (int x = 9; 8 == 10) {
int y = x;
} else {
+ // CIR: cir.scope {
+ // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+ // CIR-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init]
+ // CIR-NEXT: %4 = cir.const #cir.int<9> : !s32i
+ // CIR-NEXT: cir.store %4, %2 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: %5 = cir.const #cir.int<3> : !s32i
+ // CIR-NEXT: %6 = cir.load %2 : !cir.ptr<!s32i>, !s32i
+ // CIR-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i
+ // CIR-NEXT: cir.store %7, %3 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: }
int y = 3*x;
}
+
if constexpr (10 == 10) {
+ // CIR: cir.scope {
+ // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+ // CIR-NEXT: %3 = cir.const #cir.int<20> : !s32i
+ // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: }
int x = 20;
}
+
if constexpr (10 == 11) {
int x = 30;
}
+
if constexpr (int x = 70; 80 == 80) {
+ // CIR: cir.scope {
+ // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+ // CIR-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init]
+ // CIR-NEXT: %4 = cir.const #cir.int<70> : !s32i
+ // CIR-NEXT: cir.store %4, %2 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: %5 = cir.const #cir.int<10> : !s32i
+ // CIR-NEXT: %6 = cir.load %2 : !cir.ptr<!s32i>, !s32i
+ // CIR-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i
+ // CIR-NEXT: cir.store %7, %3 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: }
int y = 10*x;
}
+
if constexpr (int x = 90; 80 == 100) {
+ // CIR: cir.scope {
+ // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+ // CIR-NEXT: %3 = cir.const #cir.int<90> : !s32i
+ // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
+ // CIR-NEXT: }
int y = 11*x;
}
}
-
-// CHECK: cir.func dso_local @_Z3if0v() {{.*}}
-// CHECK: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: cir.scope {
-// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
-// CHECK-NEXT: %3 = cir.const #cir.int<2> : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: } loc({{.*}})
-// CHECK-NEXT: cir.scope {
-// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
-// CHECK-NEXT: %3 = cir.const #cir.int<5> : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: } loc({{.*}})
-// CHECK-NEXT: cir.scope {
-// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
-// CHECK-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init] {{.*}}
-// CHECK-NEXT: %4 = cir.const #cir.int<7> : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %4, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: %5 = cir.load{{.*}} %2 : !cir.ptr<!s32i>, !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %5, %3 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: } loc({{.*}})
-// CHECK-NEXT: cir.scope {
-// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
-// CHECK-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init] {{.*}}
-// CHECK-NEXT: %4 = cir.const #cir.int<9> : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %4, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: %5 = cir.const #cir.int<3> : !s32i loc({{.*}})
-// CHECK-NEXT: %6 = cir.load{{.*}} %2 : !cir.ptr<!s32i>, !s32i loc({{.*}})
-// CHECK-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %7, %3 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: } loc({{.*}})
-// CHECK-NEXT: cir.scope {
-// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
-// CHECK-NEXT: %3 = cir.const #cir.int<20> : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: } loc({{.*}})
-// CHECK-NEXT: cir.scope {
-// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
-// CHECK-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init] {{.*}}
-// CHECK-NEXT: %4 = cir.const #cir.int<70> : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %4, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: %5 = cir.const #cir.int<10> : !s32i loc({{.*}})
-// CHECK-NEXT: %6 = cir.load{{.*}} %2 : !cir.ptr<!s32i>, !s32i loc({{.*}})
-// CHECK-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %7, %3 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: } loc({{.*}})
-// CHECK-NEXT: cir.scope {
-// CHECK-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {{.*}}
-// CHECK-NEXT: %3 = cir.const #cir.int<90> : !s32i loc({{.*}})
-// CHECK-NEXT: cir.store{{.*}} %3, %2 : !s32i, !cir.ptr<!s32i> loc({{.*}})
-// CHECK-NEXT: } loc({{.*}})
-// CHECK-NEXT: cir.return loc({{.*}})
>From b7c862d920a02070d77aa3b0fac907cf2907be07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:36:48 +0300
Subject: [PATCH 11/57] Rename bitfieils.c to bitfields.c
---
clang/test/CIR/Lowering/{bitfieils.c => bitfields.c} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename clang/test/CIR/Lowering/{bitfieils.c => bitfields.c} (100%)
diff --git a/clang/test/CIR/Lowering/bitfieils.c b/clang/test/CIR/Lowering/bitfields.c
similarity index 100%
rename from clang/test/CIR/Lowering/bitfieils.c
rename to clang/test/CIR/Lowering/bitfields.c
>From d3ef94fd6414d93ce24c5a27ddad17d0cbc359de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 10:43:59 +0300
Subject: [PATCH 12/57] Delete clang/test/CIR/CodeGen/complex-cast.c
I'll revisit these kinds of tests
OGCG
---
clang/test/CIR/CodeGen/complex-cast.c | 264 --------------------------
1 file changed, 264 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/complex-cast.c
diff --git a/clang/test/CIR/CodeGen/complex-cast.c b/clang/test/CIR/CodeGen/complex-cast.c
deleted file mode 100644
index 5212625694447..0000000000000
--- a/clang/test/CIR/CodeGen/complex-cast.c
+++ /dev/null
@@ -1,264 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -mmlir --mlir-print-ir-before=cir-lowering-prepare -o %t.cir %s 2>&1 | FileCheck --check-prefixes=CIR-BEFORE,CHECK %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir -mmlir --mlir-print-ir-after=cir-lowering-prepare -o %t.cir %s 2>&1 | FileCheck --check-prefixes=CIR-AFTER,CHECK %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm -o %t.ll %s
-// RUN: FileCheck --input-file=%t.ll --check-prefixes=LLVM,CHECK %s
-
-#include <stdbool.h>
-
-volatile double _Complex cd;
-volatile float _Complex cf;
-volatile int _Complex ci;
-volatile short _Complex cs;
-volatile double sd;
-volatile int si;
-volatile bool b;
-
-void scalar_to_complex() {
- cd = sd;
- ci = si;
- cd = si;
- ci = sd;
-}
-
-// CHECK-LABEL: @scalar_to_complex()
-
-// CIR-BEFORE: %{{.+}} = cir.cast(float_to_complex, %{{.+}} : !cir.double), !cir.complex<!cir.double>
-
-// CIR-AFTER: %[[#REAL:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!cir.double>, !cir.double
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
-
-// CIR-BEFORE: %{{.+}} = cir.cast(int_to_complex, %{{.+}} : !s32i), !cir.complex<!s32i>
-
-// CIR-AFTER: %[[#REAL:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!s32i>, !s32i
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
-
-// CIR-BEFORE: %[[#A:]] = cir.cast(int_to_float, %{{.+}} : !s32i), !cir.double
-// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(float_to_complex, %[[#A]] : !cir.double), !cir.complex<!cir.double>
-
-// CIR-AFTER: %[[#A:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!s32i>, !s32i
-// CIR-AFTER-NEXT: %[[#REAL:]] = cir.cast(int_to_float, %[[#A]] : !s32i), !cir.double
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
-
-// CIR-BEFORE: %[[#A:]] = cir.cast(float_to_int, %{{.+}} : !cir.double), !s32i
-// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(int_to_complex, %[[#A]] : !s32i), !cir.complex<!s32i>
-
-// CIR-AFTER: %[[#A:]] = cir.load volatile{{.*}} %{{.+}} : !cir.ptr<!cir.double>, !cir.double
-// CIR-AFTER-NEXT: %[[#REAL:]] = cir.cast(float_to_int, %[[#A]] : !cir.double), !s32i
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
-
-// LLVM: %[[#REAL:]] = load volatile double, ptr @sd, align 8
-// LLVM-NEXT: %[[#A:]] = insertvalue { double, double } {{.*}}, double %[[#REAL]], 0
-// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double 0.000000e+00, 1
-
-// LLVM: %[[#REAL:]] = load volatile i32, ptr @si, align 4
-// LLVM-NEXT: %[[#A:]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL]], 0
-// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 0, 1
-
-// LLVM: %[[#A:]] = load volatile i32, ptr @si, align 4
-// LLVM-NEXT: %[[#REAL:]] = sitofp i32 %[[#A]] to double
-// LLVM-NEXT: %[[#B:]] = insertvalue { double, double } {{.*}}, double %[[#REAL]], 0
-// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#B]], double 0.000000e+00, 1
-
-// LLVM: %[[#A:]] = load volatile double, ptr @sd, align 8
-// LLVM-NEXT: %[[#REAL:]] = fptosi double %[[#A]] to i32
-// LLVM-NEXT: %[[#B:]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL]], 0
-// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#B]], i32 0, 1
-
-// CHECK: }
-
-void scalar_to_complex_explicit() {
- cd = (double _Complex)sd;
- ci = (int _Complex)si;
- cd = (double _Complex)si;
- ci = (int _Complex)sd;
-}
-
-// CHECK-LABEL: @scalar_to_complex_explicit()
-
-// CIR-BEFORE: %{{.+}} = cir.cast(float_to_complex, %{{.+}} : !cir.double), !cir.complex<!cir.double>
-
-// CIR-AFTER: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %{{.+}}, %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
-
-// LLVM: %[[#A:]] = insertvalue { double, double } {{.*}}, double %{{.+}}, 0
-// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double 0.000000e+00, 1
-
-// CIR-BEFORE: %{{.+}} = cir.cast(int_to_complex, %{{.+}} : !s32i), !cir.complex<!s32i>
-
-// CIR-AFTER: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %{{.+}}, %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
-
-// LLVM: %[[#A:]] = insertvalue { i32, i32 } {{.*}}, i32 %{{.+}}, 0
-// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 0, 1
-
-// CIR-BEFORE: %[[#A:]] = cir.cast(int_to_float, %{{.+}} : !s32i), !cir.double
-// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(float_to_complex, %[[#A]] : !cir.double), !cir.complex<!cir.double>
-
-// CIR-AFTER: %[[#REAL:]] = cir.cast(int_to_float, %11 : !s32i), !cir.double
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.fp<0.000000e+00> : !cir.double
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !cir.double -> !cir.complex<!cir.double>
-
-// LLVM: %[[#REAL:]] = sitofp i32 %{{.+}} to double
-// LLVM-NEXT: %[[#A:]] = insertvalue { double, double } {{.*}}, double %[[#REAL]], 0
-// LLVM-NEXT: %{{.+}} = insertvalue { double, double } %[[#A]], double 0.000000e+00, 1
-
-// CIR-BEFORE: %[[#A:]] = cir.cast(float_to_int, %{{.+}} : !cir.double), !s32i
-// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(int_to_complex, %[[#A]] : !s32i), !cir.complex<!s32i>
-
-// CIR-AFTER: %[[#REAL:]] = cir.cast(float_to_int, %{{.+}} : !cir.double), !s32i
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.const #cir.int<0> : !s32i
-// CIR-AFTER-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
-
-// LLVM: %[[#REAL:]] = fptosi double %{{.+}} to i32
-// LLVM-NEXT: %[[#A:]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL]], 0
-// LLVM-NEXT: %{{.+}} = insertvalue { i32, i32 } %[[#A]], i32 0, 1
-
-// CHECK: }
-
-void complex_to_scalar() {
- sd = (double)cd;
- si = (int)ci;
- sd = (double)ci;
- si = (int)cd;
-}
-
-// CHECK-LABEL: @complex_to_scalar()
-
-// CIR-BEFORE: %{{.+}} = cir.cast(float_complex_to_real, %{{.+}} : !cir.complex<!cir.double>), !cir.double
-
-// CIR-AFTER: %{{.+}} = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
-
-// LLVM: %{{.+}} = extractvalue { double, double } %{{.+}}, 0
-
-// CIR-BEFORE: %{{.+}} = cir.cast(int_complex_to_real, %{{.+}} : !cir.complex<!s32i>), !s32i
-
-// CIR-AFTER: %{{.+}} = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
-
-// LLVM: %{{.+}} = extractvalue { i32, i32 } %{{.+}}, 0
-
-// CIR-BEFORE: %[[#A:]] = cir.cast(int_complex_to_real, %{{.+}} : !cir.complex<!s32i>), !s32i
-// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(int_to_float, %[[#A]] : !s32i), !cir.double
-
-// CIR-AFTER: %[[#A:]] = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
-// CIR-AFTER-NEXT: %{{.+}} = cir.cast(int_to_float, %[[#A]] : !s32i), !cir.double
-
-// LLVM: %[[#A:]] = extractvalue { i32, i32 } %{{.+}}, 0
-// LLVM-NEXT: %{{.+}} = sitofp i32 %[[#A]] to double
-
-// CIR-BEFORE: %[[#A:]] = cir.cast(float_complex_to_real, %{{.+}} : !cir.complex<!cir.double>), !cir.double
-// CIR-BEFORE-NEXT: %{{.+}} = cir.cast(float_to_int, %[[#A]] : !cir.double), !s32i
-
-// CIR-AFTER: %[[#A:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
-// CIR-AFTER-NEXT: %{{.+}} = cir.cast(float_to_int, %[[#A]] : !cir.double), !s32i
-
-// LLVM: %[[#A:]] = extractvalue { double, double } %{{.+}}, 0
-// LLVM-NEXT: %{{.+}} = fptosi double %[[#A]] to i32
-
-// CHECK: }
-
-void complex_to_bool() {
- b = (bool)cd;
- b = (bool)ci;
-}
-
-// CHECK-LABEL: @complex_to_bool()
-
-// CIR-BEFORE: %{{.+}} = cir.cast(float_complex_to_bool, %{{.+}} : !cir.complex<!cir.double>), !cir.bool
-
-// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.+}} : !cir.complex<!cir.double> -> !cir.double
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.complex.imag %{{.+}} : !cir.complex<!cir.double> -> !cir.double
-// CIR-AFTER-NEXT: %[[#RB:]] = cir.cast(float_to_bool, %[[#REAL]] : !cir.double), !cir.bool
-// CIR-AFTER-NEXT: %[[#IB:]] = cir.cast(float_to_bool, %[[#IMAG]] : !cir.double), !cir.bool
-// CIR-AFTER-NEXT: %[[#A:]] = cir.const #true
-// CIR-AFTER-NEXT: %{{.+}} = cir.select if %[[#RB]] then %[[#A]] else %[[#IB]] : (!cir.bool, !cir.bool, !cir.bool) -> !cir.bool
-
-// LLVM: %[[#REAL:]] = extractvalue { double, double } %{{.+}}, 0
-// LLVM-NEXT: %[[#IMAG:]] = extractvalue { double, double } %{{.+}}, 1
-// LLVM-NEXT: %[[#RB:]] = fcmp une double %[[#REAL]], 0.000000e+00
-// LLVM-NEXT: %[[#IB:]] = fcmp une double %[[#IMAG]], 0.000000e+00
-// LLVM-NEXT: %{{.+}} = or i1 %[[#RB]], %[[#IB]]
-
-// CIR-BEFORE: %{{.+}} = cir.cast(int_complex_to_bool, %{{.+}} : !cir.complex<!s32i>), !cir.bool
-
-// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.+}} : !cir.complex<!s32i> -> !s32i
-// CIR-AFTER-NEXT: %[[#IMAG:]] = cir.complex.imag %{{.+}} : !cir.complex<!s32i> -> !s32i
-// CIR-AFTER-NEXT: %[[#RB:]] = cir.cast(int_to_bool, %[[#REAL]] : !s32i), !cir.bool
-// CIR-AFTER-NEXT: %[[#IB:]] = cir.cast(int_to_bool, %[[#IMAG]] : !s32i), !cir.bool
-// CIR-AFTER-NEXT: %[[#A:]] = cir.const #true
-// CIR-AFTER-NEXT: %{{.+}} = cir.select if %[[#RB]] then %[[#A]] else %[[#IB]] : (!cir.bool, !cir.bool, !cir.bool) -> !cir.bool
-
-// LLVM: %[[#REAL:]] = extractvalue { i32, i32 } %{{.+}}, 0
-// LLVM-NEXT: %[[#IMAG:]] = extractvalue { i32, i32 } %{{.+}}, 1
-// LLVM-NEXT: %[[#RB:]] = icmp ne i32 %[[#REAL]], 0
-// LLVM-NEXT: %[[#IB:]] = icmp ne i32 %[[#IMAG]], 0
-// LLVM-NEXT: %{{.+}} = or i1 %[[#RB]], %[[#IB]]
-
-// CHECK: }
-
-struct CX {
- double real;
- double imag;
-};
-
-void lvalue_to_rvalue_bitcast() {
- struct CX a;
- double _Complex b = __builtin_bit_cast(double _Complex, a);
-}
-
-// CHECK-LABEL: @lvalue_to_rvalue_bitcast()
-
-// CIR-BEFORE: %{{.+}} = cir.cast(bitcast, %{{.+}} : !cir.ptr<!rec_CX>), !cir.ptr<!cir.complex<!cir.double>>
-
-// CIR-AFTER: %{{.+}} = cir.cast(bitcast, %{{.+}} : !cir.ptr<!rec_CX>), !cir.ptr<!cir.complex<!cir.double>>
-
-// LLVM: %[[PTR_ADDR:.*]] = alloca %struct.CX, i64 1, align 8
-// LLVM: %[[COMPLEX_ADDR:.*]] = alloca { double, double }, i64 1, align 8
-// LLVM: %[[PTR_TO_COMPLEX:.*]] = load { double, double }, ptr %[[PTR_ADDR]], align 8
-// LLVM: store { double, double } %[[PTR_TO_COMPLEX]], ptr %[[COMPLEX_ADDR]], align 8
-
-// CHECK: }
-
-void complex_to_complex_cast() {
- cd = cf;
- ci = cs;
-}
-
-// CIR-BEFORE: %[[TMP:.*]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>
-// CIR-BEFORE: %[[FP_COMPLEX:.*]] = cir.cast(float_complex, %[[TMP]] : !cir.complex<!cir.float>), !cir.complex<!cir.double>
-
-// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.*}} : !cir.complex<!cir.float> -> !cir.float
-// CIR-AFTER: %[[#IMAG:]] = cir.complex.imag %{{.*}} : !cir.complex<!cir.float> -> !cir.float
-// CIR-AFTER: %[[#REAL_FP_CAST:]] = cir.cast(floating, %[[#REAL]] : !cir.float), !cir.double
-// CIR-AFTER: %[[#IMAG_FP_CAST:]] = cir.cast(floating, %[[#IMAG]] : !cir.float), !cir.double
-// CIR-AFTER: %{{.*}} = cir.complex.create %[[#REAL_FP_CAST]], %[[#IMAG_FP_CAST]] : !cir.double -> !cir.complex<!cir.double>
-
-// LLVM: %[[#REAL:]] = extractvalue { float, float } %{{.*}}, 0
-// LLVM: %[[#IMAG:]] = extractvalue { float, float } %{{.*}}, 1
-// LLVM: %[[#REAL_FP_CAST:]] = fpext float %[[#REAL]] to double
-// LLVM: %[[#IMAG_FP_CAST:]] = fpext float %[[#IMAG]] to double
-// LLVM: %[[TMP:.*]] = insertvalue { double, double } {{.*}}, double %[[#REAL_FP_CAST]], 0
-// LLVM: %{{.*}} = insertvalue { double, double } %[[TMP]], double %[[#IMAG_FP_CAST]], 1
-
-// CIR-BEFORE: %[[TMP:.*]] = cir.load{{.*}} %{{.*}} : !cir.ptr<!cir.complex<!s16i>>, !cir.complex<!s16i>
-// CIR-BEFORE: %[[INT_COMPLEX:.*]] = cir.cast(int_complex, %[[TMP]] : !cir.complex<!s16i>), !cir.complex<!s32i>
-
-// CIR-AFTER: %[[#REAL:]] = cir.complex.real %{{.*}} : !cir.complex<!s16i> -> !s16i
-// CIR-AFTER: %[[#IMAG:]] = cir.complex.imag %{{.*}} : !cir.complex<!s16i> -> !s16i
-// CIR-AFTER: %[[#REAL_INT_CAST:]] = cir.cast(integral, %[[#REAL]] : !s16i), !s32i
-// CIR-AFTER: %[[#IMAG_INT_CAST:]] = cir.cast(integral, %[[#IMAG]] : !s16i), !s32i
-// CIR-AFTER: %{{.*}} = cir.complex.create %[[#REAL_INT_CAST]], %[[#IMAG_INT_CAST]] : !s32i -> !cir.complex<!s32i>
-
-// LLVM: %[[#REAL:]] = extractvalue { i16, i16 } %{{.*}}, 0
-// LLVM: %[[#IMAG:]] = extractvalue { i16, i16 } %{{.*}}, 1
-// LLVM: %[[#REAL_INT_CAST:]] = sext i16 %[[#REAL]] to i32
-// LLVM: %[[#IMAG_INT_CAST:]] = sext i16 %[[#IMAG]] to i32
-// LLVM: %[[TMP:.*]] = insertvalue { i32, i32 } {{.*}}, i32 %[[#REAL_INT_CAST]], 0
-// LLVM: %{{.*}} = insertvalue { i32, i32 } %[[TMP]], i32 %[[#IMAG_INT_CAST]], 1
-
-void promotion() {
- cd = cf + cf;
-}
>From 9658f7e0d58d7423c1ea79048d0946349e772099 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Tue, 9 Sep 2025 21:40:47 +0300
Subject: [PATCH 13/57] Delete clang/test/CIR/test.c
Unnecessary Placeholder Deleted
---
clang/test/CIR/test.c | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 clang/test/CIR/test.c
diff --git a/clang/test/CIR/test.c b/clang/test/CIR/test.c
deleted file mode 100644
index 5c1031cccc41a..0000000000000
--- a/clang/test/CIR/test.c
+++ /dev/null
@@ -1 +0,0 @@
-// RUN: true
>From fdc981c9a13db63d08e555f883d9fb0f779194fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:48:40 +0300
Subject: [PATCH 14/57] Delete clang/test/CIR/CodeGen/binassign.cpp
---
clang/test/CIR/CodeGen/binassign.cpp | 71 ----------------------------
1 file changed, 71 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/binassign.cpp
diff --git a/clang/test/CIR/CodeGen/binassign.cpp b/clang/test/CIR/CodeGen/binassign.cpp
deleted file mode 100644
index c33cdfd228871..0000000000000
--- a/clang/test/CIR/CodeGen/binassign.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-int foo(int a, int b) {
- int x = a * b;
- x *= b;
- x /= b;
- x %= b;
- x += b;
- x -= b;
- x >>= b;
- x <<= b;
- x &= b;
- x ^= b;
- x |= b;
- return x;
-}
-
-// CHECK: [[Value:%[0-9]+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
-// CHECK: = cir.binop(mul,
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(mul,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: cir.binop(div,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(rem,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(add,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(sub,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.shift(right
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.shift(left
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(and,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(xor,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-// CHECK: = cir.load {{.*}}[[Value]]
-// CHECK: = cir.binop(or,
-// CHECK: cir.store{{.*}} {{.*}}[[Value]]
-
-typedef enum {
- A = 3,
-} enumy;
-
-enumy getty();
-
-void exec() {
- enumy r;
- if ((r = getty()) < 0) {}
-}
-
-// CHECK: cir.func dso_local @_Z4execv()
-// CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["r"]
-// CHECK: cir.scope {
-// CHECK: %1 = cir.call @_Z5gettyv() : () -> !u32i
-// CHECK: cir.store{{.*}} %1, %0 : !u32i, !cir.ptr<!u32i>
-// CHECK: %2 = cir.cast(integral, %1 : !u32i), !s32i
-// CHECK: %3 = cir.const #cir.int<0> : !s32i
-// CHECK: %4 = cir.cmp(lt, %2, %3) : !s32i, !cir.bool
-// CHECK: cir.if %4 {
>From f46bdd39189aae1d821070fcd2b4fe85f8b477a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:49:07 +0300
Subject: [PATCH 15/57] Delete clang/test/CIR/CodeGen/comma.cpp
---
clang/test/CIR/CodeGen/comma.cpp | 30 ------------------------------
1 file changed, 30 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/comma.cpp
diff --git a/clang/test/CIR/CodeGen/comma.cpp b/clang/test/CIR/CodeGen/comma.cpp
deleted file mode 100644
index e10be4ac02288..0000000000000
--- a/clang/test/CIR/CodeGen/comma.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-int c0() {
- int a = 1;
- int b = 2;
- return b + 1, a;
-}
-
-// CHECK: cir.func dso_local @_Z2c0v() -> !s32i
-// CHECK: %[[#RET:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
-// CHECK: %[[#A:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init]
-// CHECK: %[[#B:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["b", init]
-// CHECK: %[[#LOADED_B:]] = cir.load{{.*}} %[[#B]] : !cir.ptr<!s32i>, !s32i
-// CHECK: %[[#]] = cir.binop(add, %[[#LOADED_B]], %[[#]]) nsw : !s32i
-// CHECK: %[[#LOADED_A:]] = cir.load{{.*}} %[[#A]] : !cir.ptr<!s32i>, !s32i
-// CHECK: cir.store{{.*}} %[[#LOADED_A]], %[[#RET]] : !s32i, !cir.ptr<!s32i>
-
-int &foo1();
-int &foo2();
-
-void c1() {
- int &x = (foo1(), foo2());
-}
-
-// CHECK: cir.func dso_local @_Z2c1v()
-// CHECK: %0 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
-// CHECK: %1 = cir.call @_Z4foo1v() : () -> !cir.ptr<!s32i>
-// CHECK: %2 = cir.call @_Z4foo2v() : () -> !cir.ptr<!s32i>
-// CHECK: cir.store{{.*}} %2, %0 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
>From c85d11fd6b94857b3f04c8c1c3caa6f32e93f98f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:49:36 +0300
Subject: [PATCH 16/57] Delete clang/test/CIR/CodeGen/compound-literal-empty.c
---
.../test/CIR/CodeGen/compound-literal-empty.c | 18 ------------------
1 file changed, 18 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/compound-literal-empty.c
diff --git a/clang/test/CIR/CodeGen/compound-literal-empty.c b/clang/test/CIR/CodeGen/compound-literal-empty.c
deleted file mode 100644
index b0007d96b4cb2..0000000000000
--- a/clang/test/CIR/CodeGen/compound-literal-empty.c
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll
-// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
-
-short b() { return (short){}; }
-
-// CIR-LABEL: b
-// CIR: {{%.*}} = cir.alloca !s16i, !cir.ptr<!s16i>, [".compoundliteral"] {alignment = 2 : i64}
-
-// LLVM-LABEL: b
-// LLVM: [[RET_P:%.*]] = alloca i16, i64 1, align 2
-// LLVM: [[LITERAL:%.*]] = alloca i16, i64 1, align 2
-// LLVM: store i16 0, ptr [[LITERAL]], align 2
-// LLVM: [[T0:%.*]] = load i16, ptr [[LITERAL]], align 2
-// LLVM: store i16 [[T0]], ptr [[RET_P]], align 2
-// LLVM: [[T1:%.*]] = load i16, ptr [[RET_P]], align 2
-// LLVM: ret i16 [[T1]]
>From 5a1a09d14875b2c981fb517cf49ccee5d559511e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:49:52 +0300
Subject: [PATCH 17/57] Delete clang/test/CIR/CodeGen/func_dsolocal_pie.c
---
clang/test/CIR/CodeGen/func_dsolocal_pie.c | 34 ----------------------
1 file changed, 34 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/func_dsolocal_pie.c
diff --git a/clang/test/CIR/CodeGen/func_dsolocal_pie.c b/clang/test/CIR/CodeGen/func_dsolocal_pie.c
deleted file mode 100644
index f3e524ce2fdb3..0000000000000
--- a/clang/test/CIR/CodeGen/func_dsolocal_pie.c
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir -pic-is-pie -pic-level 1 %s -o %t1.cir
-// RUN: FileCheck --input-file=%t1.cir %s -check-prefix=CIR
-// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm -pic-is-pie -pic-level 1 %s -o %t.ll
-// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
-
-void foo(int i) {
-
-}
-
-int main() {
- foo(2);
- return 0;
-}
-
-// CIR: cir.func dso_local @foo(%arg0: !s32i
-// CIR-NEXT: [[TMP0:%.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
-// CIR-NEXT: cir.store %arg0, [[TMP0]] : !s32i, !cir.ptr<!s32i>
-// CIR-NEXT: cir.return
-
-// CIR: cir.func no_proto dso_local @main() -> !s32i
-// CIR: [[TMP1:%.*]] = cir.const #cir.int<2> : !s32i
-// CIR: cir.call @foo([[TMP1]]) : (!s32i) -> ()
-
-// LLVM: define dso_local void @foo(i32 [[TMP3:%.*]])
-// LLVM: [[ARG_STACK:%.*]] = alloca i32, i64 1, align 4
-// LLVM: store i32 [[TMP3]], ptr [[ARG_STACK]], align 4
-// LLVM: ret void
-
-// LLVM: define dso_local i32 @main()
-// LLVM: [[TMP4:%.*]] = alloca i32, i64 1, align 4
-// LLVM: call void @foo(i32 2)
-// LLVM: store i32 0, ptr [[TMP4]], align 4
-// LLVM: [[RET_VAL:%.*]] = load i32, ptr [[TMP4]], align 4
-// LLVM: ret i32 [[RET_VAL]]
>From b64f42d9cccaf8a426aefa8d5f47462e28fbab6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:50:33 +0300
Subject: [PATCH 18/57] Delete clang/test/CIR/CodeGen/if-constexpr.cpp
---
clang/test/CIR/CodeGen/if-constexpr.cpp | 94 -------------------------
1 file changed, 94 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/if-constexpr.cpp
diff --git a/clang/test/CIR/CodeGen/if-constexpr.cpp b/clang/test/CIR/CodeGen/if-constexpr.cpp
deleted file mode 100644
index 70a08706be6ab..0000000000000
--- a/clang/test/CIR/CodeGen/if-constexpr.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
-
-void if0() {
- int x = 0;
-
- if constexpr (0 == 0) {
- // CIR: cir.scope {
- // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
- // CIR-NEXT: %3 = cir.const #cir.int<2> : !s32i
- // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: }
- int x = 2;
- } else {
- int x = 3;
- }
-
- if constexpr (0 == 1) {
- int x = 4;
- } else {
- // CIR: cir.scope {
- // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
- // CIR-NEXT: %3 = cir.const #cir.int<5> : !s32i
- // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: }
- int x = 5;
- }
-
- if constexpr (int x = 7; 8 == 8) {
- // CIR: cir.scope {
- // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
- // CIR-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init]
- // CIR-NEXT: %4 = cir.const #cir.int<7> : !s32i
- // CIR-NEXT: cir.store %4, %2 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: %5 = cir.load %2 : !cir.ptr<!s32i>, !s32i
- // CIR-NEXT: cir.store %5, %3 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: }
- int y = x;
- } else {
- int y = 2*x;
- }
-
- if constexpr (int x = 9; 8 == 10) {
- int y = x;
- } else {
- // CIR: cir.scope {
- // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
- // CIR-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init]
- // CIR-NEXT: %4 = cir.const #cir.int<9> : !s32i
- // CIR-NEXT: cir.store %4, %2 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: %5 = cir.const #cir.int<3> : !s32i
- // CIR-NEXT: %6 = cir.load %2 : !cir.ptr<!s32i>, !s32i
- // CIR-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i
- // CIR-NEXT: cir.store %7, %3 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: }
- int y = 3*x;
- }
-
- if constexpr (10 == 10) {
- // CIR: cir.scope {
- // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
- // CIR-NEXT: %3 = cir.const #cir.int<20> : !s32i
- // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: }
- int x = 20;
- }
-
- if constexpr (10 == 11) {
- int x = 30;
- }
-
- if constexpr (int x = 70; 80 == 80) {
- // CIR: cir.scope {
- // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
- // CIR-NEXT: %3 = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init]
- // CIR-NEXT: %4 = cir.const #cir.int<70> : !s32i
- // CIR-NEXT: cir.store %4, %2 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: %5 = cir.const #cir.int<10> : !s32i
- // CIR-NEXT: %6 = cir.load %2 : !cir.ptr<!s32i>, !s32i
- // CIR-NEXT: %7 = cir.binop(mul, %5, %6) nsw : !s32i
- // CIR-NEXT: cir.store %7, %3 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: }
- int y = 10*x;
- }
-
- if constexpr (int x = 90; 80 == 100) {
- // CIR: cir.scope {
- // CIR-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
- // CIR-NEXT: %3 = cir.const #cir.int<90> : !s32i
- // CIR-NEXT: cir.store %3, %2 : !s32i, !cir.ptr<!s32i>
- // CIR-NEXT: }
- int y = 11*x;
- }
-}
>From f2e979ef3305ded895d15fac9f9e73f0898a608e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:51:36 +0300
Subject: [PATCH 19/57] Update gnu89.c
---
clang/test/CIR/CodeGen/gnu89.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/gnu89.c b/clang/test/CIR/CodeGen/gnu89.c
index 5254576779aa1..26007c8f50a8c 100644
--- a/clang/test/CIR/CodeGen/gnu89.c
+++ b/clang/test/CIR/CodeGen/gnu89.c
@@ -2,4 +2,4 @@
// RUN: FileCheck --input-file=%t.cir %s
void foo() {}
-//CHECK: cir.func {{.*@foo}}
\ No newline at end of file
+// CHECK: cir.func {{.*@foo}}
>From 3bf00ca1bb5cfd24d20903b87b52a69ca99a85a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:52:27 +0300
Subject: [PATCH 20/57] Delete clang/test/CIR/CodeGen/implicit-return.cpp
---
clang/test/CIR/CodeGen/implicit-return.cpp | 26 ----------------------
1 file changed, 26 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/implicit-return.cpp
diff --git a/clang/test/CIR/CodeGen/implicit-return.cpp b/clang/test/CIR/CodeGen/implicit-return.cpp
deleted file mode 100644
index d53568d522de0..0000000000000
--- a/clang/test/CIR/CodeGen/implicit-return.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// RUN: %clang_cc1 -O0 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CHECK-O0
-// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CHECK-O2
-
-void ret_void() {}
-
-// CHECK-O0: cir.func dso_local @_Z8ret_voidv()
-// CHECK-O0-NEXT: cir.return
-// CHECK-O0-NEXT: }
-
-// CHECK-O2: cir.func dso_local @_Z8ret_voidv()
-// CHECK-O2-NEXT: cir.return
-// CHECK-O2-NEXT: }
-
-int ret_non_void() {}
-
-// CHECK-O0: cir.func dso_local @_Z12ret_non_voidv() -> !s32i
-// CHECK-O0-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
-// CHECK-O0-NEXT: cir.trap
-// CHECK-O0-NEXT: }
-
-// CHECK-O2: cir.func dso_local @_Z12ret_non_voidv() -> !s32i
-// CHECK-O2-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
-// CHECK-O2-NEXT: cir.unreachable
-// CHECK-O2-NEXT: }
>From 86f270b23475db38caedf011ba9804ae9aa375ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:52:47 +0300
Subject: [PATCH 21/57] Delete clang/test/CIR/CodeGen/lalg.c
---
clang/test/CIR/CodeGen/lalg.c | 20 --------------------
1 file changed, 20 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/lalg.c
diff --git a/clang/test/CIR/CodeGen/lalg.c b/clang/test/CIR/CodeGen/lalg.c
deleted file mode 100644
index 7a086e9d059d1..0000000000000
--- a/clang/test/CIR/CodeGen/lalg.c
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o - | FileCheck %s
-
-double dot() {
- double x = 0.0;
- double y = 0.0f;
- double result = x * y;
- return result;
-}
-
-// CHECK: %1 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["x", init]
-// CHECK-NEXT: %2 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["y", init]
-// CHECK-NEXT: %3 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["result", init]
-// CHECK-NEXT: %4 = cir.const #cir.fp<0.000000e+00> : !cir.double
-// CHECK-NEXT: cir.store{{.*}} %4, %1 : !cir.double, !cir.ptr<!cir.double>
-// CHECK-NEXT: %5 = cir.const #cir.fp<0.000000e+00> : !cir.float
-// CHECK-NEXT: %6 = cir.cast(floating, %5 : !cir.float), !cir.double
-// CHECK-NEXT: cir.store{{.*}} %6, %2 : !cir.double, !cir.ptr<!cir.double>
-// CHECK-NEXT: %7 = cir.load{{.*}} %1 : !cir.ptr<!cir.double>, !cir.double
-// CHECK-NEXT: %8 = cir.load{{.*}} %2 : !cir.ptr<!cir.double>, !cir.double
-// CHECK-NEXT: %9 = cir.binop(mul, %7, %8) : !cir.double
>From bd975303096c57c097e072db5ef4a4e0cc0011ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:53:04 +0300
Subject: [PATCH 22/57] Delete clang/test/CIR/CodeGen/loop-scope.cpp
---
clang/test/CIR/CodeGen/loop-scope.cpp | 32 ---------------------------
1 file changed, 32 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/loop-scope.cpp
diff --git a/clang/test/CIR/CodeGen/loop-scope.cpp b/clang/test/CIR/CodeGen/loop-scope.cpp
deleted file mode 100644
index cd2cc76426c1f..0000000000000
--- a/clang/test/CIR/CodeGen/loop-scope.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cpp.cir
-// RUN: FileCheck --input-file=%t.cpp.cir %s --check-prefix=CPPSCOPE
-// RUN: %clang_cc1 -x c -std=c11 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.c.cir
-// RUN: FileCheck --input-file=%t.c.cir %s --check-prefix=CSCOPE
-
-void l0(void) {
- for (int i = 0;;) {
- int j = 0;
- }
-}
-
-// CPPSCOPE: cir.func dso_local @_Z2l0v()
-// CPPSCOPE-NEXT: cir.scope {
-// CPPSCOPE-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
-// CPPSCOPE-NEXT: %1 = cir.const #cir.int<0> : !s32i
-// CPPSCOPE-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
-// CPPSCOPE-NEXT: cir.for : cond {
-
-// CPPSCOPE: } body {
-// CPPSCOPE-NEXT: cir.scope {
-// CPPSCOPE-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["j", init] {alignment = 4 : i64}
-
-// CSCOPE: cir.func dso_local @l0()
-// CSCOPE-NEXT: cir.scope {
-// CSCOPE-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init] {alignment = 4 : i64}
-// CSCOPE-NEXT: %1 = cir.const #cir.int<0> : !s32i
-// CSCOPE-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
-// CSCOPE-NEXT: cir.for : cond {
-
-// CSCOPE: } body {
-// CSCOPE-NEXT: cir.scope {
-// CSCOPE-NEXT: %2 = cir.alloca !s32i, !cir.ptr<!s32i>, ["j", init] {alignment = 4 : i64}
>From f3fa147456853754e17a7cd18f3cdc5cc39d3196 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:53:18 +0300
Subject: [PATCH 23/57] Delete clang/test/CIR/CodeGen/lvalue-refs.cpp
---
clang/test/CIR/CodeGen/lvalue-refs.cpp | 19 -------------------
1 file changed, 19 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/lvalue-refs.cpp
diff --git a/clang/test/CIR/CodeGen/lvalue-refs.cpp b/clang/test/CIR/CodeGen/lvalue-refs.cpp
deleted file mode 100644
index 82799987aaca7..0000000000000
--- a/clang/test/CIR/CodeGen/lvalue-refs.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
-
-struct String {
- long size;
-};
-
-void split(String &S) {}
-
-// CHECK: cir.func dso_local @_Z5splitR6String(%arg0: !cir.ptr<!rec_String>
-// CHECK: %0 = cir.alloca !cir.ptr<!rec_String>, !cir.ptr<!cir.ptr<!rec_String>>, ["S", init, const]
-
-void foo() {
- String s;
- split(s);
-}
-
-// CHECK: cir.func dso_local @_Z3foov()
-// CHECK: %0 = cir.alloca !rec_String, !cir.ptr<!rec_String>, ["s"]
-// CHECK: cir.call @_Z5splitR6String(%0) : (!cir.ptr<!rec_String>) -> ()
>From 53a6bb79532375c5b242c7f0d8fb4d91ec875f91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:53:34 +0300
Subject: [PATCH 24/57] Delete clang/test/CIR/CodeGen/operators.cpp
---
clang/test/CIR/CodeGen/operators.cpp | 14 --------------
1 file changed, 14 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/operators.cpp
diff --git a/clang/test/CIR/CodeGen/operators.cpp b/clang/test/CIR/CodeGen/operators.cpp
deleted file mode 100644
index 1d900188f1cee..0000000000000
--- a/clang/test/CIR/CodeGen/operators.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-class __attribute__((__visibility__("default"))) exception_ptr
-{
- void* __ptr_;
-public:
- explicit operator bool() const noexcept {return __ptr_ != nullptr;}
-};
-
-// TODO: for now only check that this doesn't crash, in the future check operator
-// bool codegen.
-
-// CHECK: module
\ No newline at end of file
>From ed80e8c59fbef49d272ca487a7d381c30ea2b4e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:53:47 +0300
Subject: [PATCH 25/57] Delete clang/test/CIR/CodeGen/return.cpp
---
clang/test/CIR/CodeGen/return.cpp | 33 -------------------------------
1 file changed, 33 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/return.cpp
diff --git a/clang/test/CIR/CodeGen/return.cpp b/clang/test/CIR/CodeGen/return.cpp
deleted file mode 100644
index e77dd5e1ac04a..0000000000000
--- a/clang/test/CIR/CodeGen/return.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
-
-int &ret0(int &x) {
- return x;
-}
-
-// CHECK: cir.func dso_local @_Z4ret0Ri
-// CHECK: %0 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["x", init, const] {alignment = 8 : i64}
-// CHECK: %1 = cir.alloca !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>, ["__retval"] {alignment = 8 : i64}
-// CHECK: cir.store{{.*}} %arg0, %0 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
-// CHECK: %2 = cir.load %0 : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
-// CHECK: cir.store{{.*}} %2, %1 : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>>
-// CHECK: %3 = cir.load %1 : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
-// CHECK: cir.return %3 : !cir.ptr<!s32i>
-
-int unreachable_after_return() {
- return 0;
- return 1;
-}
-
-// CHECK: cir.func dso_local @_Z24unreachable_after_returnv
-// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] {alignment = 4 : i64}
-// CHECK-NEXT: %1 = cir.const #cir.int<0> : !s32i
-// CHECK-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
-// CHECK-NEXT: cir.br ^bb1
-// CHECK-NEXT: ^bb1: // 2 preds: ^bb0, ^bb2
-// CHECK-NEXT: %2 = cir.load %0 : !cir.ptr<!s32i>, !s32i
-// CHECK-NEXT: cir.return %2 : !s32i
-// CHECK-NEXT: ^bb2: // no predecessors
-// CHECK-NEXT: %3 = cir.const #cir.int<1> : !s32i
-// CHECK-NEXT: cir.store{{.*}} %3, %0 : !s32i, !cir.ptr<!s32i>
-// CHECK-NEXT: cir.br ^bb1
-// CHECK-NEXT: }
>From 696e8049d96cc0ee9cbadc469dee4703eeb3b16b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:53:59 +0300
Subject: [PATCH 26/57] Delete clang/test/CIR/CodeGen/shift.cpp
---
clang/test/CIR/CodeGen/shift.cpp | 8 --------
1 file changed, 8 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/shift.cpp
diff --git a/clang/test/CIR/CodeGen/shift.cpp b/clang/test/CIR/CodeGen/shift.cpp
deleted file mode 100644
index 6f6a10d34ab08..0000000000000
--- a/clang/test/CIR/CodeGen/shift.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-unsigned long s(int i, unsigned long x) {
- return x << i;
-}
-
-// CHECK: cir.shift(left, %3 : !u64i, %4 : !s32i) -> !u64i
\ No newline at end of file
>From 9d390f1b982c2c6a59600851b550456a08c3deb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:54:16 +0300
Subject: [PATCH 27/57] Delete clang/test/CIR/CodeGen/store.c
---
clang/test/CIR/CodeGen/store.c | 29 -----------------------------
1 file changed, 29 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/store.c
diff --git a/clang/test/CIR/CodeGen/store.c b/clang/test/CIR/CodeGen/store.c
deleted file mode 100644
index 7bf64773396ff..0000000000000
--- a/clang/test/CIR/CodeGen/store.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-void foo(void) {
- int a = 0;
- a = 1;
-}
-
-// CHECK: cir.func dso_local @foo()
-// CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init] {alignment = 4 : i64}
-// CHECK-NEXT: %1 = cir.const #cir.int<0> : !s32i
-// CHECK-NEXT: cir.store{{.*}} %1, %0 : !s32i, !cir.ptr<!s32i>
-// CHECK-NEXT: %2 = cir.const #cir.int<1> : !s32i
-// CHECK-NEXT: cir.store{{.*}} %2, %0 : !s32i, !cir.ptr<!s32i>
-// CHECK-NEXT: cir.return
-// CHECK-NEXT: }
-
-typedef int (*fn_t)();
-int get42() { return 42; }
-
-void storeNoArgsFn() {
- fn_t f = get42;
-}
-
-// CHECK: cir.func {{.*@storeNoArgsFn}}
-// CHECK: %0 = cir.alloca
-// CHECK: %1 = cir.get_global @get42 : !cir.ptr<!cir.func<() -> !s32i>>
-// CHECK: %2 = cir.cast(bitcast, %1 : !cir.ptr<!cir.func<() -> !s32i>>), !cir.ptr<!cir.func<(...) -> !s32i>>
-// CHECK: cir.store{{.*}} %2, %0 : !cir.ptr<!cir.func<(...) -> !s32i>>, !cir.ptr<!cir.ptr<!cir.func<(...) -> !s32i>>>
>From d23e960ac6bf6710f2d13fd8bb0ea1351248691c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:54:55 +0300
Subject: [PATCH 28/57] Delete clang/test/CIR/CodeGen/types-nullptr.cpp
---
clang/test/CIR/CodeGen/types-nullptr.cpp | 9 ---------
1 file changed, 9 deletions(-)
delete mode 100644 clang/test/CIR/CodeGen/types-nullptr.cpp
diff --git a/clang/test/CIR/CodeGen/types-nullptr.cpp b/clang/test/CIR/CodeGen/types-nullptr.cpp
deleted file mode 100644
index a598a1a724f6e..0000000000000
--- a/clang/test/CIR/CodeGen/types-nullptr.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
-
-typedef decltype(nullptr) nullptr_t;
-void f() { nullptr_t t = nullptr; }
-
-// CHECK: %0 = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>
-// CHECK: %1 = cir.const #cir.ptr<null> : !cir.ptr<!void>
-// CHECK: cir.store{{.*}} %1, %0 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>
>From 10ff2897ccdaf87682125e1e2e556367c5cc302e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Wed, 10 Sep 2025 23:55:25 +0300
Subject: [PATCH 29/57] Delete clang/test/CIR/Lowering/bitfields.c
---
clang/test/CIR/Lowering/bitfields.c | 32 -----------------------------
1 file changed, 32 deletions(-)
delete mode 100644 clang/test/CIR/Lowering/bitfields.c
diff --git a/clang/test/CIR/Lowering/bitfields.c b/clang/test/CIR/Lowering/bitfields.c
deleted file mode 100644
index 19de2ab194d41..0000000000000
--- a/clang/test/CIR/Lowering/bitfields.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
-// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
-
-typedef struct {
- int a : 4;
-} B;
-
-// LLVM: define dso_local void @set_signed
-// LLVM: [[TMP0:%.*]] = load ptr
-// LLVM: [[TMP1:%.*]] = getelementptr %struct.B, ptr [[TMP0]], i32 0, i32 0
-// LLVM: [[TMP2:%.*]] = load i8, ptr [[TMP1]]
-// LLVM: [[TMP3:%.*]] = and i8 [[TMP2]], -16
-// LLVM: [[TMP4:%.*]] = or i8 [[TMP3]], 14
-// LLVM: store i8 [[TMP4]], ptr [[TMP1]]
-void set_signed(B* b) {
- b->a = -2;
-}
-
-// LLVM: define dso_local i32 @get_signed
-// LLVM: [[TMP0:%.*]] = alloca i32
-// LLVM: [[TMP1:%.*]] = load ptr
-// LLVM: [[TMP2:%.*]] = getelementptr %struct.B, ptr [[TMP1]], i32 0, i32 0
-// LLVM: [[TMP3:%.*]] = load i8, ptr [[TMP2]]
-// LLVM: [[TMP4:%.*]] = shl i8 [[TMP3]], 4
-// LLVM: [[TMP5:%.*]] = ashr i8 [[TMP4]], 4
-// LLVM: [[TMP6:%.*]] = sext i8 [[TMP5]] to i32
-// LLVM: store i32 [[TMP6]], ptr [[TMP0]]
-// LLVM: [[TMP7:%.*]] = load i32, ptr [[TMP0]]
-// LLVM: ret i32 [[TMP7]]
-int get_signed(B* b) {
- return b->a;
-}
>From 3f68776195c4b573864747759075235a8d5f7267 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 22:53:57 +0300
Subject: [PATCH 30/57] Update types.c
---
clang/test/CIR/CodeGen/types.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/CIR/CodeGen/types.c b/clang/test/CIR/CodeGen/types.c
index d409514a81d56..27a668fa97b06 100644
--- a/clang/test/CIR/CodeGen/types.c
+++ b/clang/test/CIR/CodeGen/types.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -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
// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cpp.cir
-// RUN: FileCheck --input-file=%t.cpp.cir --check-prefix=CHECK-CPP %s
+// RUN: FileCheck --input-file=%t.cpp.cir --check-prefix=CIR-CPP %s
int t0(int i) { return i; }
unsigned int t1(unsigned int i) { return i; }
>From 1a70288edbb7879ba83d804c8aa7c80e92fb5d7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 22:55:47 +0300
Subject: [PATCH 31/57] Update types-IEEE-quad.c
---
clang/test/CIR/CodeGen/types-IEEE-quad.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/test/CIR/CodeGen/types-IEEE-quad.c b/clang/test/CIR/CodeGen/types-IEEE-quad.c
index c56b3e7ca6d2b..ed916ec7d3161 100644
--- a/clang/test/CIR/CodeGen/types-IEEE-quad.c
+++ b/clang/test/CIR/CodeGen/types-IEEE-quad.c
@@ -8,10 +8,10 @@ long double t2(long double i2) {
return i2 + i ;
}
-// CIR: cir.global external @i = #cir.fp<0.000000e+00> : !cir.long_double<!cir.f128> {alignment = 16 : i64} loc({{.*}})
+// CIR: cir.global external @i = #cir.fp<0.000000e+00> : !cir.long_double<!cir.f128>
// CIR-LABEL: cir.func dso_local @t2(%arg0: !cir.long_double<!cir.f128> loc({{.*}})) -> !cir.long_double<!cir.f128>
-// CIR-NEXT: %[[#I2:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["i2", init] {alignment = 16 : i64}
-// CIR-NEXT: %[[#RETVAL:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["__retval"] {alignment = 16 : i64}
+// CIR-NEXT: %[[#I2:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["i2", init]
+// CIR-NEXT: %[[#RETVAL:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["__retval"]
// CIR-NEXT: cir.store %arg0, %[[#I2]] : !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>
// CIR-NEXT: %[[#I2_LOAD:]] = cir.load{{.*}} %[[#I2]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
// CIR-NEXT: %[[#I:]] = cir.get_global @i : !cir.ptr<!cir.long_double<!cir.f128>>
>From 4d0b234b8d95e37563ac683d63abd98444f7de18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 22:57:34 +0300
Subject: [PATCH 32/57] Update no-proto-fun-ptr.c
---
clang/test/CIR/CodeGen/no-proto-fun-ptr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
index 0dcf79f68c0f2..539c41dbc7ccf 100644
--- a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
+++ b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
@@ -20,7 +20,7 @@ void buz() {
}
// CHECK: cir.func no_proto dso_local @buz()
-// CHECK: [[FNPTR_ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<(...)>>, !cir.ptr<!cir.ptr<!cir.func<(...)>>>, ["func"] {alignment = 8 : i64}
+// CHECK: [[FNPTR_ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<(...)>>, !cir.ptr<!cir.ptr<!cir.func<(...)>>>, ["func"]
// CHECK: [[FNPTR:%.*]] = cir.load deref{{.*}} [[FNPTR_ALLOC]] : !cir.ptr<!cir.ptr<!cir.func<(...)>>>, !cir.ptr<!cir.func<(...)>>
// CHECK: [[CAST:%.*]] = cir.cast(bitcast, %1 : !cir.ptr<!cir.func<(...)>>), !cir.ptr<!cir.func<()>>
// CHECK: cir.call [[CAST]]() : (!cir.ptr<!cir.func<()>>) -> ()
>From 53f0df4a61171b198c33244972f186e35577f430 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 22:58:02 +0300
Subject: [PATCH 33/57] Update no-pie.c
---
clang/test/CIR/CodeGen/no-pie.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/no-pie.c b/clang/test/CIR/CodeGen/no-pie.c
index 0639fd34c3633..2330955dbbe6e 100644
--- a/clang/test/CIR/CodeGen/no-pie.c
+++ b/clang/test/CIR/CodeGen/no-pie.c
@@ -7,5 +7,5 @@ extern int var;
int get() {
return var;
}
-// CIR: cir.global "private" external dso_local @var : !s32i {alignment = 4 : i64}
+// CIR: cir.global "private" external dso_local @var : !s32i
// LLVM: @var = external dso_local global i32
>From b12a6840d56a045385bd0b7a9b1b65588dcaa1f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 22:59:31 +0300
Subject: [PATCH 34/57] Update inc-bool.cpp
---
clang/test/CIR/CodeGen/inc-bool.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/inc-bool.cpp b/clang/test/CIR/CodeGen/inc-bool.cpp
index 17557d338ce0a..58404eee1f635 100644
--- a/clang/test/CIR/CodeGen/inc-bool.cpp
+++ b/clang/test/CIR/CodeGen/inc-bool.cpp
@@ -6,7 +6,7 @@ void foo(bool x) {
}
// CHECK: cir.func dso_local @_Z3foob(%arg0: !cir.bool loc({{.*}}))
-// CHECK: [[ALLOC_X:%.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init] {alignment = 1 : i64}
+// CHECK: [[ALLOC_X:%.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init]
// CHECK: cir.store{{.*}} %arg0, [[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
// CHECK: {{.*}} = cir.load{{.*}} [[ALLOC_X]] : !cir.ptr<!cir.bool>, !cir.bool
// CHECK: [[TRUE:%.*]] = cir.const #true
>From 7a73171b6f04c8c8e673e0a9ae78da0f4043ac44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 23:22:25 +0300
Subject: [PATCH 35/57] Update expressions.cpp
---
clang/test/CIR/CodeGen/expressions.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/test/CIR/CodeGen/expressions.cpp b/clang/test/CIR/CodeGen/expressions.cpp
index 7324c1357f8ab..2e08740c963eb 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
void test(int a) {
-// CHECK: cir.func dso_local @{{.+}}test
+ // CHECK: cir.func dso_local @{{.+}}test
// Should generate LValue parenthesis expression.
(a) = 1;
- // CHECK: %[[#C:]] = cir.const #cir.int<1> : !s32i
- // CHECK: cir.store{{.*}} %[[#C]], %{{.+}} : !s32i, !cir.ptr<!s32i>
+ // CHECK: %[[C:.*]] = cir.const #cir.int<1> : !s32i
+ // CHECK: cir.store{{.*}} %[[C]], %{{.+}} : !s32i, !cir.ptr<!s32i>
}
>From 874a9bf98b4373e3f84e81850fe89c88dd047597 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 23:24:10 +0300
Subject: [PATCH 36/57] Update inc-bool.cpp
---
clang/test/CIR/CodeGen/inc-bool.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/inc-bool.cpp b/clang/test/CIR/CodeGen/inc-bool.cpp
index 58404eee1f635..8bac6aa645a55 100644
--- a/clang/test/CIR/CodeGen/inc-bool.cpp
+++ b/clang/test/CIR/CodeGen/inc-bool.cpp
@@ -6,7 +6,7 @@ void foo(bool x) {
}
// CHECK: cir.func dso_local @_Z3foob(%arg0: !cir.bool loc({{.*}}))
-// CHECK: [[ALLOC_X:%.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init]
+// CHECK: %[[ALLOC_X:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init]
// CHECK: cir.store{{.*}} %arg0, [[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
// CHECK: {{.*}} = cir.load{{.*}} [[ALLOC_X]] : !cir.ptr<!cir.bool>, !cir.bool
// CHECK: [[TRUE:%.*]] = cir.const #true
>From ba8d30c89da9d941576c3cefc2f379e4ec85ec87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 23:30:38 +0300
Subject: [PATCH 37/57] Update inc-bool.cpp
---
clang/test/CIR/CodeGen/inc-bool.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/test/CIR/CodeGen/inc-bool.cpp b/clang/test/CIR/CodeGen/inc-bool.cpp
index 8bac6aa645a55..e34b080ec5bb3 100644
--- a/clang/test/CIR/CodeGen/inc-bool.cpp
+++ b/clang/test/CIR/CodeGen/inc-bool.cpp
@@ -7,8 +7,8 @@ void foo(bool x) {
// CHECK: cir.func dso_local @_Z3foob(%arg0: !cir.bool loc({{.*}}))
// CHECK: %[[ALLOC_X:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init]
-// CHECK: cir.store{{.*}} %arg0, [[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
-// CHECK: {{.*}} = cir.load{{.*}} [[ALLOC_X]] : !cir.ptr<!cir.bool>, !cir.bool
-// CHECK: [[TRUE:%.*]] = cir.const #true
-// CHECK: cir.store{{.*}} [[TRUE]], [[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
+// CHECK: cir.store{{.*}} %arg0, %[[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
+// CHECK: {{.*}} = cir.load{{.*}} %[[ALLOC_X]] : !cir.ptr<!cir.bool>, !cir.bool
+// CHECK: %[[TRUE:.*]] = cir.const #true
+// CHECK: cir.store{{.*}} %[[TRUE]], %[[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
// CHECK: cir.return
>From f250c3c8f885a751df5eb1bfa8d5aff29c4f9344 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Thu, 11 Sep 2025 23:36:59 +0300
Subject: [PATCH 38/57] Update spelling-locations.cpp
---
clang/test/CIR/CodeGen/spelling-locations.cpp | 52 +++++++++----------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/clang/test/CIR/CodeGen/spelling-locations.cpp b/clang/test/CIR/CodeGen/spelling-locations.cpp
index 66c09c88a029c..0ad0c5a622f8a 100644
--- a/clang/test/CIR/CodeGen/spelling-locations.cpp
+++ b/clang/test/CIR/CodeGen/spelling-locations.cpp
@@ -11,9 +11,9 @@ int testMacroLocations(void) {
multiline_if_macro(1, 3);
// CHECK: cir.scope {
// CHECK: cir.if %{{.+}} {
- // CHECK: cir.return %{{.+}} : !s32i loc(#loc[[#LOC:]])
- // CHECK: } loc(#loc[[#LOC]])
- // CHECK: } loc(#loc[[#LOC]])
+ // CHECK: cir.return %{{.+}} : !s32i loc(#loc[[LOC:.*]])
+ // CHECK: } loc(#loc[[LOC]])
+ // CHECK: } loc(#loc[[LOC]])
// Regular if statements should use different locations.
if (1) {
@@ -21,9 +21,9 @@ int testMacroLocations(void) {
}
// CHECK: cir.scope {
// CHECK: cir.if %{{.+}} {
- // CHECK: cir.return %{{.+}} : !s32i loc(#loc[[#LOC:]])
- // CHECK-NOT: } loc(#loc[[#LOC]])
- // CHECK-NOT: } loc(#loc[[#LOC]])
+ // CHECK: cir.return %{{.+}} : !s32i loc(#loc[[LOC:.*]])
+ // CHECK-NOT: } loc(#loc[[LOC]])
+ // CHECK-NOT: } loc(#loc[[LOC]])
return 0;
}
@@ -52,21 +52,21 @@ void testIfStmtLocations(int f) {
// CHECK: cir.if %{{.+}} {
// CHECK: } else {
-// CHECK: } loc(#loc[[#LOC1:]])
+// CHECK: } loc(#loc[[LOC1:.*]])
// CHECK: cir.if %{{.+}} {
// CHECK: %{{.+}} = cir.load
// CHECK: %{{.+}} = cir.unary(inc
// CHECK: cir.store
// CHECK: } else {
-// CHECK: } loc(#loc[[#LOC2:]])
+// CHECK: } loc(#loc[[LOC2:.*]])
// CHECK: cir.if %{{.+}} {
// CHECK: } else {
// CHECK: %{{.+}} = cir.load
// CHECK: %{{.+}} = cir.unary(dec
// CHECK: cir.store
-// CHECK: } loc(#loc[[#LOC3:]])
+// CHECK: } loc(#loc[[LOC3:.*]])
// CHECK: cir.if %{{.+}} {
// CHECK: %{{.+}} = cir.load
@@ -76,25 +76,25 @@ void testIfStmtLocations(int f) {
// CHECK: %{{.+}} = cir.load
// CHECK: %{{.+}} = cir.unary(dec
// CHECK: cir.store
-// CHECK: } loc(#loc[[#LOC4:]])
+// CHECK: } loc(#loc[[LOC4:.*]])
-// CHECK: #loc[[#LOC12:]] = loc({{.+}}:35:5)
-// CHECK: #loc[[#LOC11:]] = loc({{.+}}:33:5)
+// CHECK: #loc[[LOC12:.*]] = loc({{.+}}:35:5)
+// CHECK: #loc[[LOC11:.*]] = loc({{.+}}:33:5)
-// CHECK: #loc[[#LOC23:]] = loc({{.+}}:40:5)
-// CHECK: #loc[[#LOC21:]] = loc({{.+}}:38:5)
-// CHECK: #loc[[#LOC22:]] = loc({{.+}}:38:7)
+// CHECK: #loc[[LOC23:.*]] = loc({{.+}}:40:5)
+// CHECK: #loc[[LOC21:.*]] = loc({{.+}}:38:5)
+// CHECK: #loc[[LOC22:.*]] = loc({{.+}}:38:7)
-// CHECK: #loc[[#LOC33:]] = loc({{.+}}:45:7)
-// CHECK: #loc[[#LOC31:]] = loc({{.+}}:43:5)
-// CHECK: #loc[[#LOC32:]] = loc({{.+}}:45:5)
+// CHECK: #loc[[LOC33:.*]] = loc({{.+}}:45:7)
+// CHECK: #loc[[LOC31:.*]] = loc({{.+}}:43:5)
+// CHECK: #loc[[LOC32:.*]] = loc({{.+}}:45:5)
-// CHECK: #loc[[#LOC44:]] = loc({{.+}}:50:7)
-// CHECK: #loc[[#LOC41:]] = loc({{.+}}:48:5)
-// CHECK: #loc[[#LOC42:]] = loc({{.+}}:48:7)
-// CHECK: #loc[[#LOC43:]] = loc({{.+}}:50:5)
+// CHECK: #loc[[LOC44:.*]] = loc({{.+}}:50:7)
+// CHECK: #loc[[LOC41:.*]] = loc({{.+}}:48:5)
+// CHECK: #loc[[LOC42:.*]] = loc({{.+}}:48:7)
+// CHECK: #loc[[LOC43:.*]] = loc({{.+}}:50:5)
-// CHECK: #loc[[#LOC1]] = loc(fused[#loc[[#LOC11]], #loc[[#LOC12]]])
-// CHECK: #loc[[#LOC2]] = loc(fused[#loc[[#LOC21]], #loc[[#LOC22]], #loc[[#LOC23]]])
-// CHECK: #loc[[#LOC3]] = loc(fused[#loc[[#LOC31]], #loc[[#LOC32]], #loc[[#LOC33]]])
-// CHECK: #loc[[#LOC4]] = loc(fused[#loc[[#LOC41]], #loc[[#LOC42]], #loc[[#LOC43]], #loc[[#LOC44]]])
+// CHECK: #loc[[LOC1]] = loc(fused[#loc[[LOC11]], #loc[[LOC12]]])
+// CHECK: #loc[[LOC2]] = loc(fused[#loc[[LOC21]], #loc[[LOC22]], #loc[[LOC23]]])
+// CHECK: #loc[[LOC3]] = loc(fused[#loc[[LOC31]], #loc[[LOC32]], #loc[[LOC33]]])
+// CHECK: #loc[[LOC4]] = loc(fused[#loc[[LOC41]], #loc[[LOC42]], #loc[[LOC43]], #loc[[LOC44]]])
>From 69c40b1c2759e218689282d8e5f115b4203122d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 00:27:20 +0300
Subject: [PATCH 39/57] Update inc-dec.cpp
---
clang/test/CIR/CodeGen/inc-dec.cpp | 49 +++++++++++++++---------------
1 file changed, 24 insertions(+), 25 deletions(-)
diff --git a/clang/test/CIR/CodeGen/inc-dec.cpp b/clang/test/CIR/CodeGen/inc-dec.cpp
index c8aa62198c819..0fe0b33779981 100644
--- a/clang/test/CIR/CodeGen/inc-dec.cpp
+++ b/clang/test/CIR/CodeGen/inc-dec.cpp
@@ -7,13 +7,12 @@ unsigned id0() {
}
// CHECK: cir.func dso_local @_Z3id0v() -> !u32i
-// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
-// CHECK: %[[#AFTER_A:]] = cir.unary(inc, %[[#BEFORE_A]])
-// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
-// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#RET]]
-
+// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CHECK: %[[AFTER_A:.*]] = cir.unary(inc, %[[BEFORE_A]]) : !u32i
+// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
+// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
unsigned id1() {
unsigned a = 1;
@@ -21,12 +20,12 @@ unsigned id1() {
}
// CHECK: cir.func dso_local @_Z3id1v() -> !u32i
-// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
-// CHECK: %[[#AFTER_A:]] = cir.unary(dec, %[[#BEFORE_A]])
-// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
-// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#RET]]
+// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CHECK: %[[AFTER_A:.*]] = cir.unary(dec, %[[BEFORE_A]]) : !u32i
+// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
+// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
unsigned id2() {
unsigned a = 1;
@@ -34,12 +33,12 @@ unsigned id2() {
}
// CHECK: cir.func dso_local @_Z3id2v() -> !u32i
-// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
-// CHECK: %[[#AFTER_A:]] = cir.unary(inc, %[[#BEFORE_A]])
-// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
-// CHECK: cir.store{{.*}} %[[#BEFORE_A]], %[[#RET]]
+// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CHECK: %[[AFTER_A:.*]] = cir.unary(inc, %[[BEFORE_A]]) : !u32i
+// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i}
+// CHECK: cir.store{{.*}} %[[BEFORE_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
unsigned id3() {
unsigned a = 1;
@@ -47,9 +46,9 @@ unsigned id3() {
}
// CHECK: cir.func dso_local @_Z3id3v() -> !u32i
-// CHECK: %[[#RET:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[#A:]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[#BEFORE_A:]] = cir.load{{.*}} %[[#A]]
-// CHECK: %[[#AFTER_A:]] = cir.unary(dec, %[[#BEFORE_A]])
-// CHECK: cir.store{{.*}} %[[#AFTER_A]], %[[#A]]
-// CHECK: cir.store{{.*}} %[[#BEFORE_A]], %[[#RET]]
+// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CHECK: %[[AFTER_A:.*]] = cir.unary(dec, %[[BEFORE_A]]) : !u32i
+// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i}
+// CHECK: cir.store{{.*}} %[[BEFORE_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
>From d5cb902d60e7a89d79e7f6e453946c3d305c4c15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 00:28:24 +0300
Subject: [PATCH 40/57] Update no-proto-fun-ptr.c
---
clang/test/CIR/CodeGen/no-proto-fun-ptr.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
index 539c41dbc7ccf..a66171706588e 100644
--- a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
+++ b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
@@ -6,10 +6,10 @@ void check_noproto_ptr() {
void (*fun)(void) = empty;
}
-// CHECK: cir.func no_proto dso_local @check_noproto_ptr()
-// CHECK: [[ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>, ["fun", init] {alignment = 8 : i64}
-// CHECK: [[GGO:%.*]] = cir.get_global @empty : !cir.ptr<!cir.func<()>>
-// CHECK: cir.store{{.*}} [[GGO]], [[ALLOC]] : !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>
+// CHECK: cir.func no_proto dso_local @check_noproto_ptr()
+// CHECK: %[[ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>, ["fun", init] {alignment = 8 : i64}
+// CHECK: %[[GGO:.*]] = cir.get_global @empty : !cir.ptr<!cir.func<()>>
+// CHECK: cir.store{{.*}} %[[GGO]], %[[ALLOC]] : !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>
// CHECK: cir.return
void empty(void) {}
@@ -19,9 +19,9 @@ void buz() {
(*func)();
}
-// CHECK: cir.func no_proto dso_local @buz()
-// CHECK: [[FNPTR_ALLOC:%.*]] = cir.alloca !cir.ptr<!cir.func<(...)>>, !cir.ptr<!cir.ptr<!cir.func<(...)>>>, ["func"]
-// CHECK: [[FNPTR:%.*]] = cir.load deref{{.*}} [[FNPTR_ALLOC]] : !cir.ptr<!cir.ptr<!cir.func<(...)>>>, !cir.ptr<!cir.func<(...)>>
-// CHECK: [[CAST:%.*]] = cir.cast(bitcast, %1 : !cir.ptr<!cir.func<(...)>>), !cir.ptr<!cir.func<()>>
-// CHECK: cir.call [[CAST]]() : (!cir.ptr<!cir.func<()>>) -> ()
+// CHECK: cir.func no_proto dso_local @buz()
+// CHECK: %[[FNPTR_ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<(...)>>, !cir.ptr<!cir.ptr<!cir.func<(...)>>>, ["func"]
+// CHECK: %[[FNPTR:.*]] = cir.load deref{{.*}} %[[FNPTR_ALLOC]] : !cir.ptr<!cir.ptr<!cir.func<(...)>>>, !cir.ptr<!cir.func<(...)>>
+// CHECK: %[[CAST:.*]] = cir.cast(bitcast, %[[FNPTR]] : !cir.ptr<!cir.func<(...)>>), !cir.ptr<!cir.func<()>>
+// CHECK: cir.call %[[CAST]]() : (!cir.ptr<!cir.func<()>>) -> ()
// CHECK: cir.return
>From d88d5f78c2611a0e3ddad8fb3fb8eae8ab1716ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 00:36:12 +0300
Subject: [PATCH 41/57] Update null-arithmatic-expression.c
---
clang/test/CIR/CodeGen/null-arithmatic-expression.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/CIR/CodeGen/null-arithmatic-expression.c b/clang/test/CIR/CodeGen/null-arithmatic-expression.c
index a59a89e151f7c..10bcd572cb22d 100644
--- a/clang/test/CIR/CodeGen/null-arithmatic-expression.c
+++ b/clang/test/CIR/CodeGen/null-arithmatic-expression.c
@@ -7,6 +7,6 @@ char *foo() {
}
// CHECK: cir.func no_proto dso_local @foo()
-// CHECK: [[CONST_1:%[0-9]+]] = cir.const #cir.int<1> : !s32i
-// CHECK: {{.*}} = cir.cast(int_to_ptr, [[CONST_1]] : !s32i)
+// CHECK: %[[CONST_1:.*]] = cir.const #cir.int<1> : !s32i
+// CHECK: {{.*}} = cir.cast(int_to_ptr, %[[CONST_1]] : !s32i)
// CHECK: cir.return
>From 8aca17839c2ef5ac0b2f0cd01580260343d14d4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 00:37:55 +0300
Subject: [PATCH 42/57] Update types-IEEE-quad.c
---
clang/test/CIR/CodeGen/types-IEEE-quad.c | 39 ++++++++++++------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/clang/test/CIR/CodeGen/types-IEEE-quad.c b/clang/test/CIR/CodeGen/types-IEEE-quad.c
index ed916ec7d3161..830c93e9e490a 100644
--- a/clang/test/CIR/CodeGen/types-IEEE-quad.c
+++ b/clang/test/CIR/CodeGen/types-IEEE-quad.c
@@ -10,23 +10,24 @@ long double t2(long double i2) {
// CIR: cir.global external @i = #cir.fp<0.000000e+00> : !cir.long_double<!cir.f128>
// CIR-LABEL: cir.func dso_local @t2(%arg0: !cir.long_double<!cir.f128> loc({{.*}})) -> !cir.long_double<!cir.f128>
-// CIR-NEXT: %[[#I2:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["i2", init]
-// CIR-NEXT: %[[#RETVAL:]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["__retval"]
-// CIR-NEXT: cir.store %arg0, %[[#I2]] : !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>
-// CIR-NEXT: %[[#I2_LOAD:]] = cir.load{{.*}} %[[#I2]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
-// CIR-NEXT: %[[#I:]] = cir.get_global @i : !cir.ptr<!cir.long_double<!cir.f128>>
-// CIR-NEXT: %[[#I_LOAD:]] = cir.load{{.*}} %[[#I]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
-// CIR-NEXT: %[[#ADD:]] = cir.binop(add, %[[#I2_LOAD]], %[[#I_LOAD]]) : !cir.long_double<!cir.f128>
-// CIR-NEXT: cir.store %[[#ADD]], %[[#RETVAL]] : !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>
-// CIR-NEXT: %[[#RETVAL_LOAD:]] = cir.load{{.*}} %[[#RETVAL]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
-// CIR-NEXT: cir.return %[[#RETVAL_LOAD]] : !cir.long_double<!cir.f128>
+// CIR-NEXT: %[[I2:.*]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["i2", init]
+// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>, ["__retval"]
+// CIR-NEXT: cir.store %arg0, %[[I2]] : !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>
+// CIR-NEXT: %[[I2_LOAD:.*]] = cir.load{{.*}} %[[I2]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
+// CIR-NEXT: %[[I:.*]] = cir.get_global @i : !cir.ptr<!cir.long_double<!cir.f128>>
+// CIR-NEXT: %[[I_LOAD:.*]] = cir.load{{.*}} %[[I]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
+// CIR-NEXT: %[[ADD:.*]] = cir.binop(add, %[[I2_LOAD]], %[[I_LOAD]]) : !cir.long_double<!cir.f128>
+// CIR-NEXT: cir.store %[[ADD]], %[[RETVAL]] : !cir.long_double<!cir.f128>, !cir.ptr<!cir.long_double<!cir.f128>>
+// CIR-NEXT: %[[RETVAL_LOAD:.*]] = cir.load{{.*}} %[[RETVAL]] : !cir.ptr<!cir.long_double<!cir.f128>>, !cir.long_double<!cir.f128>
+// CIR-NEXT: cir.return %[[RETVAL_LOAD]] : !cir.long_double<!cir.f128>
+
+// LLVM: @i = global fp128 0xL00000000000000000000000000000000, align 16
+// LLVM-LABEL: define dso_local fp128 @t2(fp128 noundef %i2)
+// LLVM-NEXT : entry:
+// LLVM-NEXT : %[[I2_ADDR:.*]]= alloca fp128, align 16
+// LLVM-NEXT : store fp128 %i2, ptr %[[I2_ADDR]], align 16
+// LLVM-NEXT : %[[I2_LOAD:.*]] = load fp128, ptr %[[I2_ADDR]], align 16
+// LLVM-NEXT : %[[I_LOAD:.*]] = load fp128, ptr @i, align 16
+// LLVM-NEXT : %[[RETVAL:.*]] = fadd fp128 %[[I2_LOAD]], %[[I_LOAD]]
+// LLVM-NEXT : ret fp128 %[[RETVAL]]
-//LLVM: @i = global fp128 0xL00000000000000000000000000000000, align 16
-//LLVM-LABEL: define dso_local fp128 @t2(fp128 noundef %i2)
-//LLVM-NEXT : entry:
-//LLVM-NEXT : %[[#I2_ADDR:]]= alloca fp128, align 16
-//LLVM-NEXT : store fp128 %i2, ptr %[[#I2_ADDR]], align 16
-//LLVM-NEXT : %[[#I2_LOAD:]] = load fp128, ptr %[[#I2_ADDR]], align 16
-//LLVM-NEXT : %[[#I_LOAD:]] = load fp128, ptr @i, align 16
-//LLVM-NEXT : %[[#RETVAL:]] = fadd fp128 %[[#I2_LOAD]], %[[#I_LOAD]]
-//LLVM-NEXT : ret fp128 %[[#RETVAL]]
>From b1e55cf59524ab48a29155e430151f41f96a6533 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 00:39:09 +0300
Subject: [PATCH 43/57] Update unary.c
---
clang/test/CIR/CodeGen/unary.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/clang/test/CIR/CodeGen/unary.c b/clang/test/CIR/CodeGen/unary.c
index ebcae89e2bdb0..b112c34308ffd 100644
--- a/clang/test/CIR/CodeGen/unary.c
+++ b/clang/test/CIR/CodeGen/unary.c
@@ -4,41 +4,41 @@
int valueNegationInt(int i) {
// CHECK: cir.func dso_local @valueNegationInt(
return !i;
- // CHECK: %[[#INT:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s32i>, !s32i
- // CHECK: %[[#INT_TO_BOOL:]] = cir.cast(int_to_bool, %[[#INT]] : !s32i), !cir.bool
- // CHECK: = cir.unary(not, %[[#INT_TO_BOOL]]) : !cir.bool, !cir.bool
+ // CHECK: %[[INT:.*]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s32i>, !s32i
+ // CHECK: %[[INT_TO_BOOL:.*]] = cir.cast(int_to_bool, %[[INT]] : !s32i), !cir.bool
+ // CHECK: = cir.unary(not, %[[INT_TO_BOOL]]) : !cir.bool, !cir.bool
}
short valueNegationShort(short s) {
// CHECK: cir.func dso_local @valueNegationShort(
return !s;
- // CHECK: %[[#SHORT:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s16i>, !s16i
- // CHECK: %[[#SHORT_TO_BOOL:]] = cir.cast(int_to_bool, %[[#SHORT]] : !s16i), !cir.bool
- // CHECK: = cir.unary(not, %[[#SHORT_TO_BOOL]]) : !cir.bool, !cir.bool
+ // CHECK: %[[SHORT:.*]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s16i>, !s16i
+ // CHECK: %[[SHORT_TO_BOOL:.*]] = cir.cast(int_to_bool, %[[SHORT]] : !s16i), !cir.bool
+ // CHECK: = cir.unary(not, %[[SHORT_TO_BOOL]]) : !cir.bool, !cir.bool
}
long valueNegationLong(long l) {
// CHECK: cir.func dso_local @valueNegationLong(
return !l;
- // CHECK: %[[#LONG:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s64i>, !s64i
- // CHECK: %[[#LONG_TO_BOOL:]] = cir.cast(int_to_bool, %[[#LONG]] : !s64i), !cir.bool
- // CHECK: = cir.unary(not, %[[#LONG_TO_BOOL]]) : !cir.bool, !cir.bool
+ // CHECK: %[[LONG:.*]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!s64i>, !s64i
+ // CHECK: %[[LONG_TO_BOOL:.*]] = cir.cast(int_to_bool, %[[LONG]] : !s64i), !cir.bool
+ // CHECK: = cir.unary(not, %[[LONG_TO_BOOL]]) : !cir.bool, !cir.bool
}
float valueNegationFloat(float f) {
// CHECK: cir.func dso_local @valueNegationFloat(
return !f;
- // CHECK: %[[#FLOAT:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!cir.float>, !cir.float
- // CHECK: %[[#FLOAT_TO_BOOL:]] = cir.cast(float_to_bool, %[[#FLOAT]] : !cir.float), !cir.bool
- // CHECK: %[[#FLOAT_NOT:]] = cir.unary(not, %[[#FLOAT_TO_BOOL]]) : !cir.bool, !cir.bool
- // CHECK: = cir.cast(bool_to_int, %[[#FLOAT_NOT]] : !cir.bool), !s32i
+ // CHECK: %[[FLOAT:.*]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!cir.float>, !cir.float
+ // CHECK: %[[FLOAT_TO_BOOL:.*]] = cir.cast(float_to_bool, %[[FLOAT]] : !cir.float), !cir.bool
+ // CHECK: %[[FLOAT_NOT:.*]] = cir.unary(not, %[[FLOAT_TO_BOOL]]) : !cir.bool, !cir.bool
+ // CHECK: = cir.cast(bool_to_int, %[[FLOAT_NOT]] : !cir.bool), !s32i
}
double valueNegationDouble(double d) {
// CHECK: cir.func dso_local @valueNegationDouble(
return !d;
- // CHECK: %[[#DOUBLE:]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!cir.double>, !cir.double
- // CHECK: %[[#DOUBLE_TO_BOOL:]] = cir.cast(float_to_bool, %[[#DOUBLE]] : !cir.double), !cir.bool
- // CHECK: %[[#DOUBLE_NOT:]] = cir.unary(not, %[[#DOUBLE_TO_BOOL]]) : !cir.bool, !cir.bool
- // CHECK: = cir.cast(bool_to_int, %[[#DOUBLE_NOT]] : !cir.bool), !s32i
+ // CHECK: %[[DOUBLE:.*]] = cir.load{{.*}} %{{[0-9]+}} : !cir.ptr<!cir.double>, !cir.double
+ // CHECK: %[[DOUBLE_TO_BOOL:.*]] = cir.cast(float_to_bool, %[[DOUBLE]] : !cir.double), !cir.bool
+ // CHECK: %[[DOUBLE_NOT:.*]] = cir.unary(not, %[[DOUBLE_TO_BOOL]]) : !cir.bool, !cir.bool
+ // CHECK: = cir.cast(bool_to_int, %[[DOUBLE_NOT]] : !cir.bool), !s32i
}
>From 057be494246997f1bd306ee4a8fedb72ddcf831b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 00:59:56 +0300
Subject: [PATCH 44/57] Update no-proto-fun-ptr.c
---
clang/test/CIR/CodeGen/no-proto-fun-ptr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
index a66171706588e..f34fa6aff65df 100644
--- a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
+++ b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
@@ -7,7 +7,7 @@ void check_noproto_ptr() {
}
// CHECK: cir.func no_proto dso_local @check_noproto_ptr()
-// CHECK: %[[ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>, ["fun", init] {alignment = 8 : i64}
+// CHECK: %[[ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>, ["fun", init]
// CHECK: %[[GGO:.*]] = cir.get_global @empty : !cir.ptr<!cir.func<()>>
// CHECK: cir.store{{.*}} %[[GGO]], %[[ALLOC]] : !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>
// CHECK: cir.return
>From ab0fc47406afee90a9959e15a0f4f58850a8f510 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 12:35:45 +0300
Subject: [PATCH 45/57] Update expressions.cpp
---
clang/test/CIR/CodeGen/expressions.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/expressions.cpp b/clang/test/CIR/CodeGen/expressions.cpp
index 2e08740c963eb..7780b559f6945 100644
--- a/clang/test/CIR/CodeGen/expressions.cpp
+++ b/clang/test/CIR/CodeGen/expressions.cpp
@@ -1,5 +1,5 @@
// 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 dso_local @{{.+}}test
>From b5468eec7643e1e38fde26d056ef76d9233dfc97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 13:53:28 +0300
Subject: [PATCH 46/57] Update gnu89.c
---
clang/test/CIR/CodeGen/gnu89.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/gnu89.c b/clang/test/CIR/CodeGen/gnu89.c
index 26007c8f50a8c..29183e3f96bca 100644
--- a/clang/test/CIR/CodeGen/gnu89.c
+++ b/clang/test/CIR/CodeGen/gnu89.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -std=gnu89 -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 foo() {}
// CHECK: cir.func {{.*@foo}}
>From e2fabb08bfdb5c349191378c2690e020e8b7865e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 13:57:28 +0300
Subject: [PATCH 47/57] Update inc-bool.cpp
---
clang/test/CIR/CodeGen/inc-bool.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/clang/test/CIR/CodeGen/inc-bool.cpp b/clang/test/CIR/CodeGen/inc-bool.cpp
index e34b080ec5bb3..df96391b30a2d 100644
--- a/clang/test/CIR/CodeGen/inc-bool.cpp
+++ b/clang/test/CIR/CodeGen/inc-bool.cpp
@@ -1,14 +1,15 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++14 -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 foo(bool x) {
x++;
}
-// CHECK: cir.func dso_local @_Z3foob(%arg0: !cir.bool loc({{.*}}))
-// CHECK: %[[ALLOC_X:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init]
-// CHECK: cir.store{{.*}} %arg0, %[[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
-// CHECK: {{.*}} = cir.load{{.*}} %[[ALLOC_X]] : !cir.ptr<!cir.bool>, !cir.bool
-// CHECK: %[[TRUE:.*]] = cir.const #true
-// CHECK: cir.store{{.*}} %[[TRUE]], %[[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
-// CHECK: cir.return
+// CIR: cir.func dso_local @_Z3foob(%arg0: !cir.bool loc({{.*}}))
+// CIR: %[[ALLOC_X:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["x", init]
+// CIR: cir.store{{.*}} %arg0, %[[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
+// CIR: {{.*}} = cir.load{{.*}} %[[ALLOC_X]] : !cir.ptr<!cir.bool>, !cir.bool
+// CIR: %[[TRUE:.*]] = cir.const #true
+// CIR: cir.store{{.*}} %[[TRUE]], %[[ALLOC_X]] : !cir.bool, !cir.ptr<!cir.bool>
+// CIR: cir.return
+
>From 257543ac3f35b2139f11a1b1e6190e5c6d8a566e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 13:58:55 +0300
Subject: [PATCH 48/57] Update inc-dec.cpp
---
clang/test/CIR/CodeGen/inc-dec.cpp | 59 +++++++++++++++---------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/clang/test/CIR/CodeGen/inc-dec.cpp b/clang/test/CIR/CodeGen/inc-dec.cpp
index 0fe0b33779981..f6439c8452653 100644
--- a/clang/test/CIR/CodeGen/inc-dec.cpp
+++ b/clang/test/CIR/CodeGen/inc-dec.cpp
@@ -1,54 +1,55 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -Wno-unused-value -emit-cir %s -o %t.cir
-// RUN: FileCheck --input-file=%t.cir %s
+// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
unsigned id0() {
unsigned a = 1;
return ++a;
}
-// CHECK: cir.func dso_local @_Z3id0v() -> !u32i
-// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
-// CHECK: %[[AFTER_A:.*]] = cir.unary(inc, %[[BEFORE_A]]) : !u32i
-// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
-// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.func dso_local @_Z3id0v() -> !u32i
+// CIR: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CIR: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CIR: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CIR: %[[AFTER_A:.*]] = cir.unary(inc, %[[BEFORE_A]]) : !u32i
+// CIR: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.store{{.*}} %[[AFTER_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
unsigned id1() {
unsigned a = 1;
return --a;
}
-// CHECK: cir.func dso_local @_Z3id1v() -> !u32i
-// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
-// CHECK: %[[AFTER_A:.*]] = cir.unary(dec, %[[BEFORE_A]]) : !u32i
-// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
-// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.func dso_local @_Z3id1v() -> !u32i
+// CIR: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CIR: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CIR: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CIR: %[[AFTER_A:.*]] = cir.unary(dec, %[[BEFORE_A]]) : !u32i
+// CIR: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.store{{.*}} %[[AFTER_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
unsigned id2() {
unsigned a = 1;
return a++;
}
-// CHECK: cir.func dso_local @_Z3id2v() -> !u32i
-// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
-// CHECK: %[[AFTER_A:.*]] = cir.unary(inc, %[[BEFORE_A]]) : !u32i
-// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i}
-// CHECK: cir.store{{.*}} %[[BEFORE_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.func dso_local @_Z3id2v() -> !u32i
+// CIR: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CIR: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CIR: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CIR: %[[AFTER_A:.*]] = cir.unary(inc, %[[BEFORE_A]]) : !u32i
+// CIR: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.store{{.*}} %[[BEFORE_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
unsigned id3() {
unsigned a = 1;
return a--;
}
-// CHECK: cir.func dso_local @_Z3id3v() -> !u32i
-// CHECK: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
-// CHECK: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
-// CHECK: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
-// CHECK: %[[AFTER_A:.*]] = cir.unary(dec, %[[BEFORE_A]]) : !u32i
-// CHECK: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i}
-// CHECK: cir.store{{.*}} %[[BEFORE_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.func dso_local @_Z3id3v() -> !u32i
+// CIR: %[[RET:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"]
+// CIR: %[[A:.*]] = cir.alloca !u32i, !cir.ptr<!u32i>, ["a", init]
+// CIR: %[[BEFORE_A:.*]] = cir.load{{.*}} %[[A]] : !cir.ptr<!u32i>, !u32i
+// CIR: %[[AFTER_A:.*]] = cir.unary(dec, %[[BEFORE_A]]) : !u32i
+// CIR: cir.store{{.*}} %[[AFTER_A]], %[[A]] : !u32i, !cir.ptr<!u32i>
+// CIR: cir.store{{.*}} %[[BEFORE_A]], %[[RET]] : !u32i, !cir.ptr<!u32i>
+
>From 1dfce4ef53a3ae9300523b0107517874bb90a8a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 14:02:28 +0300
Subject: [PATCH 49/57] Update no-proto-fun-ptr.c
---
clang/test/CIR/CodeGen/no-proto-fun-ptr.c | 24 +++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
index f34fa6aff65df..5d99c0f215c56 100644
--- a/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
+++ b/clang/test/CIR/CodeGen/no-proto-fun-ptr.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR
void empty();
@@ -6,11 +6,11 @@ void check_noproto_ptr() {
void (*fun)(void) = empty;
}
-// CHECK: cir.func no_proto dso_local @check_noproto_ptr()
-// CHECK: %[[ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>, ["fun", init]
-// CHECK: %[[GGO:.*]] = cir.get_global @empty : !cir.ptr<!cir.func<()>>
-// CHECK: cir.store{{.*}} %[[GGO]], %[[ALLOC]] : !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>
-// CHECK: cir.return
+// CIR: cir.func no_proto dso_local @check_noproto_ptr()
+// CIR: %[[ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>, ["fun", init]
+// CIR: %[[GGO:.*]] = cir.get_global @empty : !cir.ptr<!cir.func<()>>
+// CIR: cir.store{{.*}} %[[GGO]], %[[ALLOC]] : !cir.ptr<!cir.func<()>>, !cir.ptr<!cir.ptr<!cir.func<()>>>
+// CIR: cir.return
void empty(void) {}
@@ -19,9 +19,9 @@ void buz() {
(*func)();
}
-// CHECK: cir.func no_proto dso_local @buz()
-// CHECK: %[[FNPTR_ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<(...)>>, !cir.ptr<!cir.ptr<!cir.func<(...)>>>, ["func"]
-// CHECK: %[[FNPTR:.*]] = cir.load deref{{.*}} %[[FNPTR_ALLOC]] : !cir.ptr<!cir.ptr<!cir.func<(...)>>>, !cir.ptr<!cir.func<(...)>>
-// CHECK: %[[CAST:.*]] = cir.cast(bitcast, %[[FNPTR]] : !cir.ptr<!cir.func<(...)>>), !cir.ptr<!cir.func<()>>
-// CHECK: cir.call %[[CAST]]() : (!cir.ptr<!cir.func<()>>) -> ()
-// CHECK: cir.return
+// CIR: cir.func no_proto dso_local @buz()
+// CIR: %[[FNPTR_ALLOC:.*]] = cir.alloca !cir.ptr<!cir.func<(...)>>, !cir.ptr<!cir.ptr<!cir.func<(...)>>>, ["func"]
+// CIR: %[[FNPTR:.*]] = cir.load deref{{.*}} %[[FNPTR_ALLOC]] : !cir.ptr<!cir.ptr<!cir.func<(...)>>>, !cir.ptr<!cir.func<(...)>>
+// CIR: %[[CAST:.*]] = cir.cast(bitcast, %[[FNPTR]] : !cir.ptr<!cir.func<(...)>>), !cir.ptr<!cir.func<()>>
+// CIR: cir.call %[[CAST]]() : (!cir.ptr<!cir.func<()>>) -> ()
+// CIR: cir.return
>From 71170b8ef185d19842a9338f116d61939b0ac7b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 14:04:32 +0300
Subject: [PATCH 50/57] Update no-proto-is-void.cpp
---
clang/test/CIR/CodeGen/no-proto-is-void.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/test/CIR/CodeGen/no-proto-is-void.cpp b/clang/test/CIR/CodeGen/no-proto-is-void.cpp
index ca917b7f90886..9cf766c19e867 100644
--- a/clang/test/CIR/CodeGen/no-proto-is-void.cpp
+++ b/clang/test/CIR/CodeGen/no-proto-is-void.cpp
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -x c++ -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
// RUN: %clang_cc1 -x c -std=c2x -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
// Both CXX and C2X don't support no-prototype functions. They default to void.
int noProto();
-// CHECK: cir.func dso_local @{{.*}}noProto{{.*}}() -> !s32i
+// CIR: cir.func dso_local @{{.*}}noProto{{.*}}() -> !s32i
int test(int x) {
return noProto();
- // CHECK {{.+}} = cir.call @{{.*}}noProto{{.*}}() : () -> !s32i
+ // CIR {{.+}} = cir.call @{{.*}}noProto{{.*}}() : () -> !s32i
}
int noProto() { return 0; }
>From 1928b0192e7c3fd6893c65d3718832ee1b931532 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 14:05:40 +0300
Subject: [PATCH 51/57] Update null-arithmatic-expression.c
---
clang/test/CIR/CodeGen/null-arithmatic-expression.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/clang/test/CIR/CodeGen/null-arithmatic-expression.c b/clang/test/CIR/CodeGen/null-arithmatic-expression.c
index 10bcd572cb22d..5cfca2f86ef5c 100644
--- a/clang/test/CIR/CodeGen/null-arithmatic-expression.c
+++ b/clang/test/CIR/CodeGen/null-arithmatic-expression.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-cir %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s --check-prefix=CIR
#define NULL ((void *)0)
@@ -6,7 +6,7 @@ char *foo() {
return (char*)NULL + 1;
}
-// CHECK: cir.func no_proto dso_local @foo()
-// CHECK: %[[CONST_1:.*]] = cir.const #cir.int<1> : !s32i
-// CHECK: {{.*}} = cir.cast(int_to_ptr, %[[CONST_1]] : !s32i)
-// CHECK: cir.return
+// CIR: cir.func no_proto dso_local @foo()
+// CIR: %[[CONST_1:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: {{.*}} = cir.cast(int_to_ptr, %[[CONST_1]] : !s32i)
+// CIR: cir.return
>From a33fe38887f985638a4ae23aa8d2e26d042dc941 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 14:06:36 +0300
Subject: [PATCH 52/57] Update pointer.cpp
---
clang/test/CIR/CodeGen/pointer.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/CIR/CodeGen/pointer.cpp b/clang/test/CIR/CodeGen/pointer.cpp
index bdf0e2103192b..ab3dd680c4771 100644
--- a/clang/test/CIR/CodeGen/pointer.cpp
+++ b/clang/test/CIR/CodeGen/pointer.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -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
// Global pointer should be zero initialized by default.
int *ptr;
-// CHECK: cir.global external @ptr = #cir.ptr<null> : !cir.ptr<!s32i>
+// CIR: cir.global external @ptr = #cir.ptr<null> : !cir.ptr<!s32i>
>From a29990af79549595b30828cb80b8c4535350c23a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 14:07:46 +0300
Subject: [PATCH 53/57] Update stmt-expr.c
---
clang/test/CIR/CodeGen/stmt-expr.c | 43 +++++++++++++++---------------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/clang/test/CIR/CodeGen/stmt-expr.c b/clang/test/CIR/CodeGen/stmt-expr.c
index cad7fc7eb1d6f..ed7d269a6aa1f 100644
--- a/clang/test/CIR/CodeGen/stmt-expr.c
+++ b/clang/test/CIR/CodeGen/stmt-expr.c
@@ -1,42 +1,43 @@
// RUN: %clang_cc1 -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
// Yields void.
void test1() { ({ }); }
-// CHECK: @test1
-// CHECK-NEXT: cir.return
+// CIR: @test1
+// CIR-NEXT: cir.return
// Yields an out-of-scope scalar.
void test2() { ({int x = 3; x; }); }
-// CHECK: @test2
-// CHECK: %[[#RETVAL:]] = cir.alloca !s32i, !cir.ptr<!s32i>
-// CHECK: cir.scope {
-// CHECK: %[[#VAR:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
+// CIR: @test2
+// CIR: %[[#RETVAL:]] = cir.alloca !s32i, !cir.ptr<!s32i>
+// CIR: cir.scope {
+// CIR: %[[#VAR:]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init]
// [...]
-// CHECK: %[[#TMP:]] = cir.load{{.*}} %[[#VAR]] : !cir.ptr<!s32i>, !s32i
-// CHECK: cir.store{{.*}} %[[#TMP]], %[[#RETVAL]] : !s32i, !cir.ptr<!s32i>
-// CHECK: }
-// CHECK: %{{.+}} = cir.load{{.*}} %[[#RETVAL]] : !cir.ptr<!s32i>, !s32i
+// CIR: %[[#TMP:]] = cir.load{{.*}} %[[#VAR]] : !cir.ptr<!s32i>, !s32i
+// CIR: cir.store{{.*}} %[[#TMP]], %[[#RETVAL]] : !s32i, !cir.ptr<!s32i>
+// CIR: }
+// CIR: %{{.+}} = cir.load{{.*}} %[[#RETVAL]] : !cir.ptr<!s32i>, !s32i
// Yields an aggregate.
struct S { int x; };
int test3() { return ({ struct S s = {1}; s; }).x; }
-// CHECK: @test3
-// CHECK: cir.scope {
-// CHECK: %[[#REF_TMP:]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["ref.tmp0"]
-// CHECK: cir.scope {
-// CHECK: %[[#VAR:]] = cir.alloca !rec_S, !cir.ptr<!rec_S>
+// CIR: @test3
+// CIR: cir.scope {
+// CIR: %[[#REF_TMP:]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["ref.tmp0"]
+// CIR: cir.scope {
+// CIR: %[[#VAR:]] = cir.alloca !rec_S, !cir.ptr<!rec_S>
// [...]
-// CHECK: cir.copy %[[#VAR]] to %[[#REF_TMP]] : !cir.ptr<!rec_S>
-// CHECK: }
-// CHECK: %[[#RETADDR:]] = cir.get_member %[[#REF_TMP]][0] {name = "x"} : !cir.ptr<!rec_S> -> !cir.ptr<!s32i>
-// CHECK: %{{.+}} = cir.load{{.*}} %[[#RETADDR]] : !cir.ptr<!s32i>, !s32i
+// CIR: cir.copy %[[#VAR]] to %[[#REF_TMP]] : !cir.ptr<!rec_S>
+// CIR: }
+// CIR: %[[#RETADDR:]] = cir.get_member %[[#REF_TMP]][0] {name = "x"} : !cir.ptr<!rec_S> -> !cir.ptr<!s32i>
+// CIR: %{{.+}} = cir.load{{.*}} %[[#RETADDR]] : !cir.ptr<!s32i>, !s32i
// Expression is wrapped in an expression attribute (just ensure it does not crash).
void test4(int x) { ({[[gsl::suppress("foo")]] x;}); }
-// CHECK: @test4
+// CIR: @test4
// TODO(cir): Missing label support.
// // Expression is wrapped in a label.
// // void test5(int x) { x = ({ label: x; }); }
+
>From 11503cfd34afc65f7a5014f6e40ca535e64f09fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 14:10:38 +0300
Subject: [PATCH 54/57] Update switch-unreachable-after-break.cpp
---
clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp b/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
index 5b72b3a02b9b5..b42b1e361a749 100644
--- a/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
+++ b/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
@@ -1,7 +1,7 @@
// 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
-// CHECK: _Z23unreachable_after_breaki
+// CIR: _Z23unreachable_after_breaki
void unreachable_after_break(int a) {
switch(a) {
case 0:
@@ -20,7 +20,7 @@ void unreachable_after_break(int a) {
// cir.yield
}
-// CHECK: _Z24unreachable_after_returni
+// CIR: _Z24unreachable_after_returni
int unreachable_after_return(int a) {
switch (a) {
case 0:
>From 5752b79821dea2cc6d35404a3c6b90edf61e1956 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 14:12:33 +0300
Subject: [PATCH 55/57] Update switch-unreachable-after-break.cpp
---
.../switch-unreachable-after-break.cpp | 53 ++++++++++---------
1 file changed, 27 insertions(+), 26 deletions(-)
diff --git a/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp b/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
index b42b1e361a749..3e6692bea55cb 100644
--- a/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
+++ b/clang/test/CIR/CodeGen/switch-unreachable-after-break.cpp
@@ -9,15 +9,15 @@ void unreachable_after_break(int a) {
break;
int x = 1;
}
- // cir.switch
- // cir.case(equal, [#cir.int<0> : !s32i]) {
- // cir.break
- // ^bb{{.*}}: // no predecessors
- // cir.break
- // ^bb{{.*}}: // no predecessors
- // %[[CONST:.*]] = cir.const #cir.int<1> : !s32i
- // cir.store align(4) {{.*}}, %[[CONST]]
- // cir.yield
+ // CIR: cir.switch
+ // CIR: cir.case(equal, [#cir.int<0> : !s32i]) {
+ // CIR: cir.break
+ // CIR: ^bb{{.*}}: // no predecessors
+ // CIR: cir.break
+ // CIR: ^bb{{.*}}: // no predecessors
+ // CIR: %[[CONST:.*]] = cir.const #cir.int<1> : !s32i
+ // CIR: cir.store align(4) {{.*}}, %[[CONST]]
+ // CIR: cir.yield
}
// CIR: _Z24unreachable_after_returni
@@ -29,21 +29,22 @@ int unreachable_after_return(int a) {
int x = 3;
}
return 2;
- // cir.switch
- // cir.case(equal, [#cir.int<0> : !s32i]) {
- // %[[CONST_ZERO:.*]] = cir.const #cir.int<0> : !s32i
- // cir.store {{.*}}, %[[CONST_ZERO]]
- // cir.br ^bb1
- // ^bb1: // 2 preds: ^bb0, ^bb2
- // cir.load
- // cir.return
- // ^bb2: // no predecessors
- // %[[CONST_ONE:.*]] = cir.const #cir.int<1> : !s32i
- // cir.store %[[CONST_ONE]]
- // cir.br ^bb1
- // ^bb3: // no predecessors
- // %[[CONST_THREE:.*]] = cir.const #cir.int<3> : !s32i
- // cir.store align(4) %[[CONST_THREE]]
- // cir.yield
- // }
+ // CIR: cir.switch
+ // CIR: cir.case(equal, [#cir.int<0> : !s32i]) {
+ // CIR: %[[CONST_ZERO:.*]] = cir.const #cir.int<0> : !s32i
+ // CIR: cir.store {{.*}}, %[[CONST_ZERO]]
+ // CIR: cir.br ^bb1
+ // CIR: ^bb1: // 2 preds: ^bb0, ^bb2
+ // CIR: cir.load
+ // CIR: cir.return
+ // CIR: ^bb2: // no predecessors
+ // CIR: %[[CONST_ONE:.*]] = cir.const #cir.int<1> : !s32i
+ // CIR: cir.store %[[CONST_ONE]]
+ // CIR: cir.br ^bb1
+ // CIR: ^bb3: // no predecessors
+ // CIR: %[[CONST_THREE:.*]] = cir.const #cir.int<3> : !s32i
+ // CIR: cir.store align(4) %[[CONST_THREE]]
+ // CIR: cir.yield
+ // CIR: }
}
+
>From 6351d1920117046d7ca19ec2f1b38e3a5195e810 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 16:36:59 +0300
Subject: [PATCH 56/57] Update gnu89.c
---
clang/test/CIR/CodeGen/gnu89.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/gnu89.c b/clang/test/CIR/CodeGen/gnu89.c
index 29183e3f96bca..e3cf026070ed9 100644
--- a/clang/test/CIR/CodeGen/gnu89.c
+++ b/clang/test/CIR/CodeGen/gnu89.c
@@ -2,4 +2,4 @@
// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
void foo() {}
-// CHECK: cir.func {{.*@foo}}
+// CIR: cir.func {{.*@foo}}
>From 069394d8ba99075f5e9e00a9b1a10976f51fc6b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burhan=20S=C3=B6=C4=9F=C3=BCt?= <burhan.sogutt at gmail.com>
Date: Fri, 12 Sep 2025 16:37:40 +0300
Subject: [PATCH 57/57] Update trap.cpp
---
clang/test/CIR/CodeGen/trap.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/trap.cpp b/clang/test/CIR/CodeGen/trap.cpp
index 83e9be7230d2b..9983c43f8c209 100644
--- a/clang/test/CIR/CodeGen/trap.cpp
+++ b/clang/test/CIR/CodeGen/trap.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -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 foo();
More information about the cfe-commits
mailing list