[clang] [CIR] Support CXXScalarValueInitExpr in AggExprEmitter (PR #237422)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 25 17:25:43 PST 2026
================
@@ -0,0 +1,48 @@
+// 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
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefixes=LLVM,LLVMCIR
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm -disable-llvm-passes %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
+
+struct S {
+ int a;
+};
+
+// CIR-LABEL: cir.func {{.*}} @_Z4testb
+// LLVM-LABEL: define {{.*}} @_Z4testb
+void test(bool b) {
+ // CIR: cir.if %{{.+}} {
+ // CIR: %[[MEM:.*]] = cir.get_member %{{.*}}[0] {name = "a"} : !cir.ptr<!rec_S> -> !cir.ptr<!s32i>
+ // CIR: %[[ZERO:.*]] = cir.const #cir.int<0> : !s32i
+ // CIR: cir.store align(4) %[[ZERO]], %[[MEM]] : !s32i, !cir.ptr<!s32i>
+ // CIR: } else {
+ // CIR: %[[MEM2:.*]] = cir.get_member %{{.*}}[0] {name = "a"} : !cir.ptr<!rec_S> -> !cir.ptr<!s32i>
+ // CIR: %[[ZERO2:.*]] = cir.const #cir.int<0> : !s32i
+ // CIR: cir.store align(4) %[[ZERO2]], %[[MEM2]] : !s32i, !cir.ptr<!s32i>
+ // CIR: }
+
+ // LLVM: store i32 0, ptr %{{.*}}, align 4
+ // LLVMCIR: store i32 0, ptr %{{.*}}, align 4
----------------
andykaylor wrote:
What's happening here? Is the CIR path storing an extra value that the classic codegen path doesn't?
https://github.com/llvm/llvm-project/pull/237422
More information about the cfe-commits
mailing list