CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
199 lines
6.7 KiB
C++
199 lines
6.7 KiB
C++
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
|
|
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
|
|
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
|
|
// RUN: FileCheck --check-prefix=LLVM,LLVMCIR --input-file=%t-cir.ll %s
|
|
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
|
|
// RUN: FileCheck --check-prefix=LLVM,OGCG --input-file=%t.ll %s
|
|
|
|
struct SmallVector {
|
|
~SmallVector();
|
|
};
|
|
struct BitVector {
|
|
SmallVector Bits;
|
|
};
|
|
|
|
// The switch body is a single DeclStmt (no compound statement / explicit scope).
|
|
void simple_stmt_body(int x) {
|
|
switch (x)
|
|
BitVector bv;
|
|
}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @_Z16simple_stmt_bodyi
|
|
// CIR: cir.scope {
|
|
// CIR: cir.alloca !rec_BitVector, !cir.ptr<!rec_BitVector>, ["bv"]
|
|
// CIR: cir.switch(%{{.*}} : !s32i) {
|
|
// CIR: cir.cleanup.scope {
|
|
// CIR: cir.yield
|
|
// CIR: } cleanup normal {
|
|
// CIR: cir.call @_ZN9BitVectorD1Ev
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: }
|
|
// CIR: cir.return
|
|
|
|
// LLVM-LABEL: define{{.*}} void @_Z16simple_stmt_bodyi
|
|
// LLVM: alloca %struct.BitVector
|
|
// LLVM: switch i32 %{{.*}}, label %[[EPILOG:.*]] [
|
|
// LLVM: ]
|
|
// The CIR pipeline emits the (dead) destructor cleanup; OGCG drops it entirely.
|
|
// This is inside an unreachable block in LLVMCIR.
|
|
// LLVMCIR: call void @_ZN9BitVectorD1Ev
|
|
// OGCG: [[EPILOG]]:
|
|
// LLVM: ret void
|
|
|
|
// The switch body is a CompoundStmt, so it introduces an explicit scope and the
|
|
// declaration is emitted through the unassociated-statement path.
|
|
void compound_stmt_body(int x) {
|
|
switch (x) {
|
|
BitVector bv;
|
|
}
|
|
}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @_Z18compound_stmt_bodyi
|
|
// CIR: cir.scope {
|
|
// CIR: cir.alloca !rec_BitVector, !cir.ptr<!rec_BitVector>, ["bv"]
|
|
// CIR: cir.switch(%{{.*}} : !s32i) {
|
|
// CIR: cir.cleanup.scope {
|
|
// CIR: cir.yield
|
|
// CIR: } cleanup normal {
|
|
// CIR: cir.call @_ZN9BitVectorD1Ev
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: }
|
|
// CIR: cir.return
|
|
|
|
// LLVM-LABEL: define{{.*}} void @_Z18compound_stmt_bodyi
|
|
// LLVM: alloca %struct.BitVector
|
|
// LLVM: switch i32 %{{.*}}, label %[[EPILOG:.*]] [
|
|
// LLVM: ]
|
|
// The CIR pipeline emits the (dead) destructor cleanup; OGCG drops it entirely.
|
|
// This is inside an unreachable block in LLVMCIR.
|
|
// LLVMCIR: call void @_ZN9BitVectorD1Ev
|
|
// OGCG: [[EPILOG]]:
|
|
// LLVM: ret void
|
|
|
|
void cleanup_in_case(int x) {
|
|
switch (x) {
|
|
default:
|
|
break;
|
|
case 0:
|
|
BitVector bv;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @_Z15cleanup_in_casei
|
|
// CIR: cir.scope {
|
|
// CIR: cir.alloca !rec_BitVector, !cir.ptr<!rec_BitVector>, ["bv"]
|
|
// CIR: cir.switch(%{{.*}} : !s32i) {
|
|
// CIR: cir.case(default, []) {
|
|
// CIR: cir.break
|
|
// CIR: }
|
|
// CIR: cir.case(equal, [#cir.int<0> : !s32i]) {
|
|
// CIR: cir.cleanup.scope {
|
|
// CIR: cir.break
|
|
// CIR: ^bb[[DEAD_BLOCK:.*]]:
|
|
// CIR: cir.yield
|
|
// CIR: } cleanup normal {
|
|
// CIR: cir.call @_ZN9BitVectorD1Ev
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: }
|
|
// CIR: cir.return
|
|
|
|
// LLVM-LABEL: define{{.*}} void @_Z15cleanup_in_casei
|
|
// LLVMCIR: %[[CLEANUP_FLAG:.*]] = alloca i32
|
|
// LLVM: alloca %struct.BitVector
|
|
// LLVM: switch i32 %{{.*}}, label %[[DEFAULT:.*]] [
|
|
// LLVM: i32 0, label %[[CASE_ZERO:.*]]
|
|
// LLVM: ]
|
|
// LLVM: [[DEFAULT]]:
|
|
// LLVM: br label %[[EPILOG:.*]]
|
|
// LLVM: [[CASE_ZERO]]:
|
|
// LLVMCIR: store i32 1, ptr %[[CLEANUP_FLAG]]
|
|
// LLVMCIR: br label %[[CASE_ZERO_CLEANUP:.*]]
|
|
// LLVMCIR: [[DEAD_BLOCK:.*]]:
|
|
// LLVMCIR: store i32 0, ptr %[[CLEANUP_FLAG]]
|
|
// LLVMCIR: br label %[[CASE_ZERO_CLEANUP]]
|
|
// LLVMCIR: [[CASE_ZERO_CLEANUP]]:
|
|
// LLVM: call void @_ZN9BitVectorD1Ev
|
|
// LLVMCIR: br label %[[CLEANUP_CONTINUE:.*]]
|
|
// LLVM: br label %[[EPILOG]]
|
|
// LLVM: [[EPILOG]]:
|
|
// LLVM: ret void
|
|
|
|
void cleanup_in_while_in_switch(int x) {
|
|
switch (x)
|
|
while (x) {
|
|
default:
|
|
break;
|
|
case 0:
|
|
BitVector bv;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @_Z26cleanup_in_while_in_switchi
|
|
// CIR: cir.scope {
|
|
// CIR: cir.switch(%{{.*}} : !s32i) {
|
|
// CIR: cir.scope {
|
|
// CIR: cir.while {
|
|
// CIR: cir.condition
|
|
// CIR: } do {
|
|
// CIR: cir.scope {
|
|
// CIR: cir.alloca !rec_BitVector, !cir.ptr<!rec_BitVector>, ["bv"]
|
|
// CIR: cir.case(default, []) {
|
|
// CIR: cir.break
|
|
// CIR: }
|
|
// CIR: cir.case(equal, [#cir.int<0> : !s32i]) {
|
|
// CIR: cir.cleanup.scope {
|
|
// CIR: cir.yield
|
|
// CIR: } cleanup normal {
|
|
// CIR: cir.call @_ZN9BitVectorD1Ev
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: cir.continue
|
|
// CIR: }
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: }
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
// CIR: }
|
|
// CIR: cir.return
|
|
|
|
// LLVM-LABEL: define{{.*}} void @_Z26cleanup_in_while_in_switchi
|
|
// LLVM: alloca %struct.BitVector
|
|
// LLVM: switch i32 %{{.*}}, label %[[DEFAULT:.*]] [
|
|
// LLVM: i32 0, label %[[CASE_ZERO:.*]]
|
|
// LLVM: ]
|
|
// LLVM: [[DEAD_BLOCK:.*]]:
|
|
// LLVMCIR: br label %[[SWITCH_BODY:.*]]
|
|
// OGCG: br label %[[WHILE_COND:.*]]
|
|
// LLVMCIR: [[SWITCH_BODY]]:
|
|
// LLVMCIR: br label %[[WHILE_COND:.*]]
|
|
// LLVM: [[WHILE_COND]]:
|
|
// LLVM: icmp
|
|
// LLVM: br i1 %{{.*}}, label %[[WHILE_BODY:.*]], label %[[WHILE_END:.*]]
|
|
// LLVM: [[WHILE_BODY]]:
|
|
// LLVM: br label %[[DEFAULT]]
|
|
// LLVM: [[DEFAULT]]:
|
|
// LLVM: br label %[[WHILE_END]]
|
|
// LLVM: [[CASE_ZERO]]:
|
|
// LLVM: call void @_ZN9BitVectorD1Ev
|
|
// LLVM: br label %[[WHILE_COND]]
|
|
// LLVM: [[WHILE_END]]:
|
|
// LLVM: br label %[[EPILOG:.*]]
|
|
// LLVM: [[EPILOG]]:
|
|
// LLVM: ret void
|