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
119 lines
4.8 KiB
C++
119 lines
4.8 KiB
C++
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -fclangir -emit-cir %s -o %t.cir
|
|
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
|
|
// RUN: cir-opt --cir-flatten-cfg %t.cir -o %t-flat.cir
|
|
// RUN: FileCheck --input-file=%t-flat.cir %s --check-prefix=CIR-FLAT
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -fclangir -emit-llvm %s -o %t-cir.ll
|
|
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
|
|
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -emit-llvm %s -o %t.ll
|
|
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
|
|
|
|
// Test that a struct with a potentially-throwing destructor (noexcept(false))
|
|
// produces the correct high-level CIR (cleanup region without nothrow on the
|
|
// dtor call) and correct flattened CIR (try_call in the EH cleanup path with
|
|
// an unwind-to-terminate block).
|
|
|
|
struct ThrowingDtor {
|
|
~ThrowingDtor() noexcept(false);
|
|
void doSomething();
|
|
};
|
|
|
|
void test_throwing_dtor_cleanup() {
|
|
ThrowingDtor c;
|
|
c.doSomething();
|
|
}
|
|
|
|
// High-level: the cleanup region's dtor call does NOT have nothrow.
|
|
//
|
|
// CIR: cir.func{{.*}} @_Z26test_throwing_dtor_cleanupv()
|
|
// CIR: %[[C:.*]] = cir.alloca !rec_ThrowingDtor, !cir.ptr<!rec_ThrowingDtor>, ["c"]
|
|
// CIR: cir.cleanup.scope {
|
|
// CIR: cir.call @_ZN12ThrowingDtor11doSomethingEv(%[[C]])
|
|
// CIR: cir.yield
|
|
// CIR: } cleanup all {
|
|
// CIR: cir.call @_ZN12ThrowingDtorD1Ev(%[[C]])
|
|
// CIR: cir.yield
|
|
// CIR: }
|
|
|
|
// Flattened: body call becomes try_call. In the EH cleanup path, the dtor
|
|
// becomes a try_call that unwinds to a terminate block.
|
|
//
|
|
// CIR-FLAT: cir.func{{.*}} @_Z26test_throwing_dtor_cleanupv()
|
|
// CIR-FLAT: %[[C:.*]] = cir.alloca !rec_ThrowingDtor, !cir.ptr<!rec_ThrowingDtor>, ["c"]
|
|
// CIR-FLAT: cir.br ^[[BODY:bb[0-9]+]]
|
|
//
|
|
// Body: doSomething becomes a try_call.
|
|
// CIR-FLAT: ^[[BODY]]:
|
|
// CIR-FLAT: cir.try_call @_ZN12ThrowingDtor11doSomethingEv(%[[C]]) ^[[NORMAL_BODY:bb[0-9]+]], ^[[UNWIND:bb[0-9]+]]
|
|
//
|
|
// Normal path: dtor is a regular call (not during unwinding).
|
|
// CIR-FLAT: ^[[NORMAL_BODY]]:
|
|
// CIR-FLAT: cir.call @_ZN12ThrowingDtorD1Ev(%[[C]])
|
|
//
|
|
// EH cleanup: dtor becomes try_call with unwind to terminate.
|
|
// CIR-FLAT: cir.try_call @_ZN12ThrowingDtorD1Ev(%[[C]]) ^[[DTOR_OK:bb[0-9]+]], ^[[TERMINATE:bb[0-9]+]]
|
|
// CIR-FLAT: ^[[DTOR_OK]]:
|
|
// CIR-FLAT: cir.end_cleanup
|
|
// CIR-FLAT: cir.resume
|
|
//
|
|
// Terminate block.
|
|
// CIR-FLAT: ^[[TERMINATE]]:
|
|
// CIR-FLAT: %[[TET:.*]] = cir.eh.initiate : !cir.eh_token
|
|
// CIR-FLAT: cir.eh.terminate %[[TET]] : !cir.eh_token
|
|
|
|
// LLVM IR via the CIR pipeline. doSomething is invoked, dtor is called on
|
|
// normal path, invoked on EH path with unwind to terminate.
|
|
//
|
|
// LLVM: define dso_local void @_Z26test_throwing_dtor_cleanupv()
|
|
// LLVM-SAME: personality ptr @__gxx_personality_v0
|
|
// LLVM: %[[C:.*]] = alloca %struct.ThrowingDtor
|
|
// LLVM: invoke void @_ZN12ThrowingDtor11doSomethingEv(ptr {{.*}} %[[C]])
|
|
// LLVM: to label %[[NORMAL:.*]] unwind label %[[LPAD:.*]]
|
|
// LLVM: [[NORMAL]]:
|
|
// LLVM: call void @_ZN12ThrowingDtorD1Ev(ptr {{.*}} %[[C]])
|
|
// LLVM: [[LPAD]]:
|
|
// LLVM: landingpad { ptr, i32 }
|
|
// LLVM: cleanup
|
|
// LLVM: invoke void @_ZN12ThrowingDtorD1Ev(ptr {{.*}} %[[C]])
|
|
// LLVM: to label %[[RESUME:.*]] unwind label %[[TERMINATE:.*]]
|
|
// LLVM: [[RESUME]]:
|
|
// LLVM: resume { ptr, i32 }
|
|
// LLVM: [[TERMINATE]]:
|
|
// LLVM: landingpad { ptr, i32 }
|
|
// LLVM: catch ptr null
|
|
// LLVM: call void @__clang_call_terminate(ptr
|
|
// LLVM: unreachable
|
|
// LLVM: ret void
|
|
//
|
|
// LLVM: define linkonce_odr hidden void @__clang_call_terminate(ptr %[[EXN:.*]])
|
|
// LLVM: call ptr @__cxa_begin_catch(ptr %[[EXN]])
|
|
// LLVM: call void @_ZSt9terminatev()
|
|
// LLVM: unreachable
|
|
|
|
// Same structural flow from original Clang CodeGen.
|
|
//
|
|
// OGCG: define dso_local void @_Z26test_throwing_dtor_cleanupv()
|
|
// OGCG-SAME: personality ptr @__gxx_personality_v0
|
|
// OGCG: %[[C:.*]] = alloca %struct.ThrowingDtor
|
|
// OGCG: invoke void @_ZN12ThrowingDtor11doSomethingEv(ptr {{.*}} %[[C]])
|
|
// OGCG: to label %[[NORMAL:.*]] unwind label %[[LPAD:.*]]
|
|
// OGCG: [[NORMAL]]:
|
|
// OGCG: call void @_ZN12ThrowingDtorD1Ev(ptr {{.*}} %[[C]])
|
|
// OGCG: ret void
|
|
// OGCG: [[LPAD]]:
|
|
// OGCG: landingpad { ptr, i32 }
|
|
// OGCG: cleanup
|
|
// OGCG: invoke void @_ZN12ThrowingDtorD1Ev(ptr {{.*}} %[[C]])
|
|
// OGCG: to label %[[RESUME:.*]] unwind label %[[TERMINATE:.*]]
|
|
// OGCG: [[RESUME]]:
|
|
// OGCG: resume { ptr, i32 }
|
|
// OGCG: [[TERMINATE]]:
|
|
// OGCG: landingpad { ptr, i32 }
|
|
// OGCG: catch ptr null
|
|
// OGCG: call void @__clang_call_terminate(ptr
|
|
// OGCG: unreachable
|
|
//
|
|
// OGCG: define linkonce_odr hidden void @__clang_call_terminate(ptr {{.*}} %[[EXN:.*]])
|
|
// OGCG: call ptr @__cxa_begin_catch(ptr %[[EXN]])
|
|
// OGCG: call void @_ZSt9terminatev()
|
|
// OGCG: unreachable
|