Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/ExpandVariadics/expand-va-intrinsic-split-linkage.ll
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

245 lines
8.9 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: -p --function-signature --check-globals
; RUN: opt -mtriple=wasm32-unknown-unknown -S --passes=expand-variadics --expand-variadics-override=optimize < %s | FileCheck %s --check-prefixes=OPT
; RUN: opt -mtriple=wasm32-unknown-unknown -S --passes=expand-variadics --expand-variadics-override=lowering < %s | FileCheck %s --check-prefixes=ABI
; REQUIRES: webassembly-registered-target
; Split variadic functions into two functions:
; - one equivalent to the original, same symbol etc
; - one implementing the contents of the original but taking a valist
; IR here is applicable to any target that uses a ptr for valist
;
; Defines a function with each linkage (in the order of the llvm documentation).
; If split applies it does the same transform to each.
; Whether split applies depends on whether the ABI is being changed or not - e.g. a weak
; function is not normally useful to split as the contents cannot be called from elsewhere.
; If the ABI is being rewritten then the function is still converted. Call sites tested elsewhere.
; Update test checks doesn't emit checks for declares
declare void @sink_valist(ptr)
declare void @llvm.va_start(ptr)
declare void @llvm.va_end(ptr)
declare void @decl_simple(...)
define void @defn_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_simple(...) !prof !0 {
; OPT-NEXT: entry:
; OPT-NEXT: %va_start = alloca ptr, align 4
; OPT-NEXT: call void @llvm.lifetime.start.p0(ptr %va_start)
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va_start)
; OPT-NEXT: %0 = load ptr, ptr %va_start, align 4
; OPT-NEXT: call void @defn_simple.valist(ptr %0)
; OPT-NEXT: call void @llvm.lifetime.end.p0(ptr %va_start)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
; no declare for private
define private void @defn_private_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_private_simple(...) !prof !0 {
; OPT-NEXT: entry:
; OPT-NEXT: %va_start = alloca ptr, align 4
; OPT-NEXT: call void @llvm.lifetime.start.p0(ptr %va_start)
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va_start)
; OPT-NEXT: %0 = load ptr, ptr %va_start, align 4
; OPT-NEXT: call void @defn_private_simple.valist(ptr %0)
; OPT-NEXT: call void @llvm.lifetime.end.p0(ptr %va_start)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_private_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
; no declare for internal
define internal void @defn_internal_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_internal_simple(...) !prof !0 {
; OPT-NEXT: entry:
; OPT-NEXT: %va_start = alloca ptr, align 4
; OPT-NEXT: call void @llvm.lifetime.start.p0(ptr %va_start)
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va_start)
; OPT-NEXT: %0 = load ptr, ptr %va_start, align 4
; OPT-NEXT: call void @defn_internal_simple.valist(ptr %0)
; OPT-NEXT: call void @llvm.lifetime.end.p0(ptr %va_start)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_internal_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
; no declare for available_externally
define available_externally void @available_externally_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@available_externally_simple(...) !prof !0 {
; OPT-NEXT: %va = alloca ptr, align 4
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va)
; OPT-NEXT: call void @sink_valist(ptr %va)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@available_externally_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
; no declare for linkonce
define linkonce void @defn_linkonce_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_linkonce_simple(...) !prof !0 {
; OPT-NEXT: %va = alloca ptr, align 4
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va)
; OPT-NEXT: call void @sink_valist(ptr %va)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_linkonce_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
; no declare for weak
define weak void @defn_weak_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_weak_simple(...) !prof !0 {
; OPT-NEXT: %va = alloca ptr, align 4
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va)
; OPT-NEXT: call void @sink_valist(ptr %va)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_weak_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
; common is not applicable to functions
; appending is not applicable to functions
declare extern_weak void @decl_extern_weak_simple(...)
; no define for extern_weak
; no declare for linkonce_odr
define linkonce_odr void @defn_linkonce_odr_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_linkonce_odr_simple(...) !prof !0 {
; OPT-NEXT: %va = alloca ptr, align 4
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va)
; OPT-NEXT: call void @sink_valist(ptr %va)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_linkonce_odr_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
; no declare for weak_odr
define weak_odr void @defn_weak_odr_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_weak_odr_simple(...) !prof !0 {
; OPT-NEXT: %va = alloca ptr, align 4
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va)
; OPT-NEXT: call void @sink_valist(ptr %va)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_weak_odr_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
declare external void @decl_external_simple(...)
define external void @defn_external_simple(...) !prof !0 {
; OPT-LABEL: define {{[^@]+}}@defn_external_simple(...) !prof !0 {
; OPT-NEXT: entry:
; OPT-NEXT: %va_start = alloca ptr, align 4
; OPT-NEXT: call void @llvm.lifetime.start.p0(ptr %va_start)
; OPT-NEXT: call void @llvm.va_start.p0(ptr %va_start)
; OPT-NEXT: %0 = load ptr, ptr %va_start, align 4
; OPT-NEXT: call void @defn_external_simple.valist(ptr %0)
; OPT-NEXT: call void @llvm.lifetime.end.p0(ptr %va_start)
; OPT-NEXT: ret void
;
; ABI-LABEL: define {{[^@]+}}@defn_external_simple(ptr %varargs) !prof !0 {
; ABI-NEXT: %va = alloca ptr, align 4
; ABI-NEXT: store ptr %varargs, ptr %va, align 4
; ABI-NEXT: call void @sink_valist(ptr %va)
; ABI-NEXT: ret void
;
%va = alloca ptr, align 4
call void @llvm.va_start(ptr %va)
call void @sink_valist(ptr %va)
call void @llvm.va_end(ptr %va)
ret void
}
!0 = !{!"function_entry_count", i64 1000}
;.
; OPT: attributes #0 = { nocallback nofree nosync nounwind willreturn }
; OPT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
;.
; ABI: attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
;.
; OPT: !0 = !{!"function_entry_count", i64 1000}
;.
; ABI: !0 = !{!"function_entry_count", i64 1000}
;.