Files
TheRock/compiler/amd-llvm/clang/test/CIR/Transforms/flatten-preserve-attrs.cir
T
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

130 lines
5.3 KiB
Plaintext

// RUN: cir-opt %s -cir-flatten-cfg -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s
!s32i = !cir.int<s, 32>
!rec_SomeClass = !cir.struct<"SomeClass" {!s32i}>
// Test that argument attributes on a cir.call are preserved on the resulting
// cir.try_call after flattening.
cir.func @test_preserve_arg_attrs(%arg0 : !cir.ptr<!s32i>) {
cir.scope {
cir.try {
cir.call @takesPtr(%arg0) : (!cir.ptr<!s32i> {llvm.nonnull, llvm.noundef}) -> ()
cir.yield
} catch all (%eh_token : !cir.eh_token) {
%catch_token, %exn_ptr = cir.begin_catch %eh_token : !cir.eh_token -> (!cir.catch_token, !cir.ptr<!cir.void>)
cir.end_catch %catch_token : !cir.catch_token
cir.yield
}
}
cir.return
}
// CHECK-LABEL: cir.func @test_preserve_arg_attrs
// CHECK-SAME: (%[[ARG0:.*]]: !cir.ptr<!s32i>)
// CHECK: cir.try_call @takesPtr(%[[ARG0]]) ^{{.*}}, ^{{.*}} : (!cir.ptr<!s32i> {llvm.nonnull, llvm.noundef}) -> ()
// Test that result attributes on a cir.call are preserved on the resulting
// cir.try_call after flattening.
cir.func @test_preserve_res_attrs() {
cir.scope {
cir.try {
%0 = cir.call @returnsPtr() : () -> (!cir.ptr<!s32i> {llvm.nonnull})
cir.yield
} catch all (%eh_token : !cir.eh_token) {
%catch_token, %exn_ptr = cir.begin_catch %eh_token : !cir.eh_token -> (!cir.catch_token, !cir.ptr<!cir.void>)
cir.end_catch %catch_token : !cir.catch_token
cir.yield
}
}
cir.return
}
// CHECK-LABEL: cir.func @test_preserve_res_attrs()
// CHECK: cir.try_call @returnsPtr() ^{{.*}}, ^{{.*}} : () -> (!cir.ptr<!s32i> {llvm.nonnull})
// Test that the side_effect attribute on a cir.call is preserved on the
// resulting cir.try_call after flattening.
cir.func @test_preserve_side_effect() {
cir.scope {
cir.try {
%0 = cir.call @pureFunc() side_effect(pure) : () -> !s32i
cir.yield
} catch all (%eh_token : !cir.eh_token) {
%catch_token, %exn_ptr = cir.begin_catch %eh_token : !cir.eh_token -> (!cir.catch_token, !cir.ptr<!cir.void>)
cir.end_catch %catch_token : !cir.catch_token
cir.yield
}
}
cir.return
}
// CHECK-LABEL: cir.func @test_preserve_side_effect()
// CHECK: cir.try_call @pureFunc() ^{{.*}}, ^{{.*}} side_effect(pure) : () -> !s32i
// Test that argument attributes on an indirect cir.call are preserved on the
// resulting indirect cir.try_call after flattening.
cir.func @test_preserve_indirect_call_attrs(
%fptr : !cir.ptr<!cir.func<(!cir.ptr<!rec_SomeClass>) -> !s32i>>,
%obj : !cir.ptr<!rec_SomeClass>) {
cir.scope {
cir.try {
%0 = cir.call %fptr(%obj) : (!cir.ptr<!cir.func<(!cir.ptr<!rec_SomeClass>) -> !s32i>>, !cir.ptr<!rec_SomeClass> {llvm.nonnull}) -> !s32i
cir.yield
} catch all (%eh_token : !cir.eh_token) {
%catch_token, %exn_ptr = cir.begin_catch %eh_token : !cir.eh_token -> (!cir.catch_token, !cir.ptr<!cir.void>)
cir.end_catch %catch_token : !cir.catch_token
cir.yield
}
}
cir.return
}
// CHECK-LABEL: cir.func @test_preserve_indirect_call_attrs
// CHECK: cir.try_call %{{.*}}(%{{.*}}) ^{{.*}}, ^{{.*}} : (!cir.ptr<!cir.func<(!cir.ptr<!rec_SomeClass>) -> !s32i>>, !cir.ptr<!rec_SomeClass> {llvm.nonnull}) -> !s32i
// Test that all attribute types are preserved.
cir.func @test_preserve_all_attrs(%arg0 : !cir.ptr<!s32i>) {
cir.scope {
cir.try {
%0 = cir.call @generalFunc(%arg0) side_effect(const) : (!cir.ptr<!s32i> {llvm.nonnull, llvm.noundef}) -> (!cir.ptr<!s32i> {llvm.nonnull})
cir.yield
} catch all (%eh_token : !cir.eh_token) {
%catch_token, %exn_ptr = cir.begin_catch %eh_token : !cir.eh_token -> (!cir.catch_token, !cir.ptr<!cir.void>)
cir.end_catch %catch_token : !cir.catch_token
cir.yield
}
}
cir.return
}
// CHECK-LABEL: cir.func @test_preserve_all_attrs(%arg0: !cir.ptr<!s32i>)
// CHECK: cir.try_call @generalFunc(%arg0) ^{{bb[0-9]+}}, ^{{bb[0-9]+}} side_effect(const) : (!cir.ptr<!s32i> {llvm.nonnull, llvm.noundef}) -> (!cir.ptr<!s32i> {llvm.nonnull})
// Test that all attribute types are preserved with indirect calls.
cir.func @test_preserve_all_attrs_indirect(
%fptr : !cir.ptr<!cir.func<(!cir.ptr<!rec_SomeClass>) -> !s32i>>,
%obj : !cir.ptr<!rec_SomeClass>) {
cir.scope {
cir.try {
%0 = cir.call %fptr(%obj) side_effect(const) : (!cir.ptr<!cir.func<(!cir.ptr<!rec_SomeClass>) -> !s32i>>, !cir.ptr<!rec_SomeClass> {llvm.nonnull}) -> (!s32i {llvm.nonnull})
cir.yield
} catch all (%eh_token : !cir.eh_token) {
%catch_token, %exn_ptr = cir.begin_catch %eh_token : !cir.eh_token -> (!cir.catch_token, !cir.ptr<!cir.void>)
cir.end_catch %catch_token : !cir.catch_token
cir.yield
}
}
cir.return
}
// CHECK-LABEL: cir.func @test_preserve_all_attrs_indirect
// CHECK: %[[FN_PTR:.*]]: !cir.ptr<!cir.func<(!cir.ptr<!rec_SomeClass>) -> !s32i>>,
// CHECK-SAME: %[[OBJ:.*]]: !cir.ptr<!rec_SomeClass>
// CHECK: cir.try_call %[[FN_PTR]](%[[OBJ]]) ^{{bb[0-9]+}}, ^{{bb[0-9]+}} side_effect(const) : (!cir.ptr<!cir.func<(!cir.ptr<!rec_SomeClass>) -> !s32i>>, !cir.ptr<!rec_SomeClass> {llvm.nonnull}) -> (!s32i {llvm.nonnull})
cir.func private @generalFunc(!cir.ptr<!s32i>) -> !cir.ptr<!s32i>
cir.func private @takesPtr(!cir.ptr<!s32i>)
cir.func private @returnsPtr() -> !cir.ptr<!s32i>
cir.func private @pureFunc() -> !s32i