Files
TheRock/compiler/amd-llvm/mlir/test/Target/LLVMIR/alias.mlir
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

145 lines
3.9 KiB
MLIR

// RUN: mlir-translate -mlir-to-llvmir %s -split-input-file | FileCheck %s
llvm.func internal @callee() -> !llvm.ptr attributes {dso_local} {
%0 = llvm.mlir.zero : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.mlir.alias external @foo_alias : !llvm.ptr {
%0 = llvm.mlir.addressof @callee : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.mlir.alias external @_ZTV1D : !llvm.struct<(array<3 x ptr>)> {
%0 = llvm.mlir.addressof @callee : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
// CHECK: @foo_alias = alias ptr, ptr @callee
// CHECK: @_ZTV1D = alias { [3 x ptr] }, ptr @callee
// -----
llvm.mlir.global external @zed(42 : i32) : i32
llvm.mlir.alias external @foo : i32 {
%0 = llvm.mlir.addressof @zed : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.mlir.alias external @foo2 : i16 {
%0 = llvm.mlir.addressof @zed : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
// CHECK: @foo = alias i32, ptr @zed
// CHECK: @foo2 = alias i16, ptr @zed
// -----
llvm.mlir.global private constant @glob.private(dense<0> : tensor<32xi32>) {dso_local} : !llvm.array<32 x i32>
llvm.mlir.alias linkonce_odr hidden @glob {dso_local} : !llvm.array<32 x i32> {
%0 = llvm.mlir.constant(1234 : i64) : i64
%1 = llvm.mlir.addressof @glob.private : !llvm.ptr
%2 = llvm.ptrtoint %1 : !llvm.ptr to i64
%3 = llvm.add %2, %0 : i64
%4 = llvm.inttoptr %3 : i64 to !llvm.ptr
llvm.return %4 : !llvm.ptr
}
// CHECK: @glob = linkonce_odr hidden alias [32 x i32], inttoptr (i64 add (i64 ptrtoint (ptr @glob.private to i64), i64 1234) to ptr)
// -----
llvm.mlir.global external @v1(0 : i32) : i32
llvm.mlir.alias external @a3 : i32 {
%0 = llvm.mlir.addressof @v1 : !llvm.ptr
%1 = llvm.addrspacecast %0 : !llvm.ptr to !llvm.ptr<2>
llvm.return %1 : !llvm.ptr<2>
}
// CHECK: @a3 = alias i32, addrspacecast (ptr @v1 to ptr addrspace(2))
// -----
llvm.mlir.global private @g1(0 : i32) {dso_local} : i32
llvm.mlir.alias private @a1 {dso_local} : i32 {
%0 = llvm.mlir.addressof @g1 : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.mlir.global internal constant @g2() {dso_local} : !llvm.ptr {
%0 = llvm.mlir.addressof @a1 : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.mlir.alias private @a2 {dso_local} : !llvm.ptr {
%0 = llvm.mlir.addressof @a1 : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.mlir.global internal constant @g3() {dso_local} : !llvm.ptr {
%0 = llvm.mlir.addressof @a2 : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
// CHECK: @g1 = private global i32 0
// CHECK: @g2 = internal constant ptr @a1
// CHECK: @g3 = internal constant ptr @a2
// CHECK: @a1 = private alias i32, ptr @g1
// CHECK: @a2 = private alias ptr, ptr @a1
// -----
// Test that llvm.call and llvm.invoke can use an alias as the callee, and that
// the translation emits a call through the alias.
llvm.func @aliased_func() {
llvm.return
}
llvm.mlir.alias external @func_alias {addr_space = 0 : i32} : !llvm.ptr {
%0 = llvm.mlir.addressof @aliased_func : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.func @caller() {
llvm.call @func_alias() : () -> ()
llvm.return
}
// CHECK: @func_alias = alias ptr, ptr @aliased_func
// CHECK-LABEL: define void @caller()
// CHECK: call void @func_alias()
// -----
// Test that llvm.invoke can use an alias as the callee, and that the
// translation emits an invoke through the alias.
llvm.func @__gxx_personality_v0(...) -> i32
llvm.func @aliased_func2() {
llvm.return
}
llvm.mlir.alias external @func_alias2 {addr_space = 0 : i32} : !llvm.ptr {
%0 = llvm.mlir.addressof @aliased_func2 : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
llvm.func @invoke_caller() attributes {personality = @__gxx_personality_v0} {
llvm.invoke @func_alias2() to ^bb1 unwind ^bb2 : () -> ()
^bb1:
llvm.return
^bb2:
%0 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)>
llvm.resume %0 : !llvm.struct<(ptr, i32)>
}
// CHECK: @func_alias2 = alias ptr, ptr @aliased_func2
// CHECK-LABEL: define void @invoke_caller()
// CHECK: invoke void @func_alias2()