Files
TheRock/compiler/amd-llvm/clang/test/CIR/CodeGenCXX/simple-reinterpret-const-cast.cpp
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

45 lines
2.8 KiB
C++

// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s -check-prefix=CIR
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=LLVM
struct S { void do_thing(); };
void test_const_cast(const S &s) {
const_cast<S&>(s).do_thing();
}
// CIR: cir.func {{.*}}@_Z15test_const_castRK1S(%[[ARG:.*]]: !cir.ptr<!rec_S>{{.*}}) {{.*}}{
// CIR-NEXT: %[[ARG_ALLOCA:.*]] = cir.alloca !cir.ptr<!rec_S>, !cir.ptr<!cir.ptr<!rec_S>>, ["s", init, const]
// CIR-NEXT: cir.store %[[ARG]], %[[ARG_ALLOCA]] : !cir.ptr<!rec_S>, !cir.ptr<!cir.ptr<!rec_S>>
// CIR-NEXT: %[[ARG_LOAD:.*]] = cir.load %[[ARG_ALLOCA]] : !cir.ptr<!cir.ptr<!rec_S>>, !cir.ptr<!rec_S>
// CIR-NEXT: cir.call @_ZN1S8do_thingEv(%[[ARG_LOAD]])
// LLVM: define {{.*}}void @_Z15test_const_castRK1S(ptr{{.*}}%[[ARG:.*]])
// LLVM: %[[ARG_ALLOCA:.*]] = alloca ptr
// LLVM-NEXT: store ptr %[[ARG]], ptr %[[ARG_ALLOCA]]
// LLVM-NEXT: %[[ARG_LOAD:.*]] = load ptr, ptr %[[ARG_ALLOCA]]
// LLVM-NEXT: call void @_ZN1S8do_thingEv(ptr {{.*}}%[[ARG_LOAD]])
void call_with_ri_cast(S*&);
void call_with_ri_cast(int*&);
void test_reinterpet_cast(void *&data) {
call_with_ri_cast(reinterpret_cast<S*&>(data));
call_with_ri_cast(reinterpret_cast<int*&>(data));
}
// CIR: cir.func {{.*}}@_Z20test_reinterpet_castRPv(%[[ARG:.*]]: !cir.ptr<!cir.ptr<!void>>{{.*}}) {{.*}}{
// CIR-NEXT: %[[ARG_ALLOCA:.*]] = cir.alloca !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!cir.ptr<!cir.ptr<!void>>>, ["data", init, const]
// CIR-NEXT: cir.store %[[ARG]], %[[ARG_ALLOCA]] : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!cir.ptr<!cir.ptr<!void>>>
// CIR-NEXT: %[[ARG_LOAD:.*]] = cir.load %[[ARG_ALLOCA]] : !cir.ptr<!cir.ptr<!cir.ptr<!void>>>, !cir.ptr<!cir.ptr<!void>>
// CIR-NEXT: %[[RI_CAST:.*]] = cir.cast bitcast %[[ARG_LOAD]] : !cir.ptr<!cir.ptr<!void>> -> !cir.ptr<!cir.ptr<!rec_S>>
// CIR-NEXT: cir.call @_Z17call_with_ri_castRP1S(%[[RI_CAST]])
// CIR-NEXT: %[[ARG_LOAD:.*]] = cir.load %[[ARG_ALLOCA]] : !cir.ptr<!cir.ptr<!cir.ptr<!void>>>, !cir.ptr<!cir.ptr<!void>>
// CIR-NEXT: %[[RI_CAST:.*]] = cir.cast bitcast %[[ARG_LOAD]] : !cir.ptr<!cir.ptr<!void>> -> !cir.ptr<!cir.ptr<!s32i>>
// CIR-NEXT: cir.call @_Z17call_with_ri_castRPi(%[[RI_CAST]])
// LLVM: define dso_local void @_Z20test_reinterpet_castRPv(ptr {{.*}}%[[ARG:.*]])
// LLVM: %[[ARG_ALLOCA:.*]] = alloca ptr
// LLVM-NEXT: store ptr %[[ARG]], ptr %[[ARG_ALLOCA]]
// LLVM-NEXT: %[[ARG_LOAD:.*]] = load ptr, ptr %[[ARG_ALLOCA]]
// LLVM-NEXT: call void @_Z17call_with_ri_castRP1S(ptr {{.*}}%[[ARG_LOAD]])
// LLVM-NEXT: %[[ARG_LOAD:.*]] = load ptr, ptr %[[ARG_ALLOCA]]
// LLVM-NEXT: call void @_Z17call_with_ri_castRPi(ptr {{.*}}%[[ARG_LOAD]])