Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/ObjCARC/tail-call-invariant-enforcement.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

109 lines
3.7 KiB
LLVM

; RUN: opt -passes=objc-arc -S < %s | FileCheck %s
declare void @llvm.objc.release(ptr %x)
declare ptr @llvm.objc.retain(ptr %x)
declare ptr @llvm.objc.autorelease(ptr %x)
declare ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
declare ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %x)
declare ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %x)
declare ptr @tmp(ptr)
; Never tail call objc_autorelease.
; CHECK: define ptr @test0(ptr %x) [[NUW:#[0-9]+]] {
; CHECK: %tmp0 = call ptr @llvm.objc.autorelease(ptr %x) [[NUW]]
; CHECK: %tmp1 = call ptr @llvm.objc.autorelease(ptr %x) [[NUW]]
; CHECK: }
define ptr @test0(ptr %x) nounwind {
entry:
%tmp0 = call ptr @llvm.objc.autorelease(ptr %x)
%tmp1 = tail call ptr @llvm.objc.autorelease(ptr %x)
ret ptr %x
}
; Always tail call autoreleaseReturnValue.
; CHECK: define ptr @test1(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x) [[NUW]]
; CHECK: }
define ptr @test1(ptr %x) nounwind {
entry:
%tmp0 = call ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
%tmp1 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
ret ptr %x
}
; Always tail call objc_retain.
; CHECK: define ptr @test2(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.retain(ptr %x) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.retain(ptr %x) [[NUW]]
; CHECK: }
define ptr @test2(ptr %x) nounwind {
entry:
%tmp0 = call ptr @llvm.objc.retain(ptr %x)
%tmp1 = tail call ptr @llvm.objc.retain(ptr %x)
ret ptr %x
}
; Always tail call objc_retainAutoreleasedReturnValue unless it's annotated with
; notail.
; CHECK: define ptr @test3(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %y) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z) [[NUW]]
; CHECK: %tmp2 = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z2) [[NUW]]
; CHECK: }
define ptr @test3(ptr %x) nounwind {
entry:
%y = call ptr @tmp(ptr %x)
%tmp0 = call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %y)
%z = call ptr @tmp(ptr %x)
%tmp1 = tail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z)
%z2 = call ptr @tmp(ptr %x)
%tmp2 = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %z2)
ret ptr %x
}
; By itself, we should never change whether or not objc_release is tail called.
; CHECK: define void @test4(ptr %x) [[NUW]] {
; CHECK: call void @llvm.objc.release(ptr %x) [[NUW]]
; CHECK: tail call void @llvm.objc.release(ptr %x) [[NUW]]
; CHECK: }
define void @test4(ptr %x) nounwind {
entry:
call void @llvm.objc.release(ptr %x)
tail call void @llvm.objc.release(ptr %x)
ret void
}
; If we convert a tail called @llvm.objc.autoreleaseReturnValue to an
; @llvm.objc.autorelease, ensure that the tail call is removed.
; CHECK: define ptr @test5(ptr %x) [[NUW]] {
; CHECK: %tmp0 = call ptr @llvm.objc.autorelease(ptr %x) [[NUW]]
; CHECK: }
define ptr @test5(ptr %x) nounwind {
entry:
%tmp0 = tail call ptr @llvm.objc.autoreleaseReturnValue(ptr %x)
ret ptr %tmp0
}
; Always tail call llvm.objc.unsafeClaimAutoreleasedReturnValue.
; CHECK: define ptr @test6(ptr %x) [[NUW]] {
; CHECK: %tmp0 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %y) [[NUW]]
; CHECK: %tmp1 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %z) [[NUW]]
; CHECK: }
define ptr @test6(ptr %x) nounwind {
entry:
%y = call ptr @tmp(ptr %x)
%tmp0 = call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %y)
%z = call ptr @tmp(ptr %x)
%tmp1 = tail call ptr @llvm.objc.unsafeClaimAutoreleasedReturnValue(ptr %z)
ret ptr %x
}
; CHECK: attributes [[NUW]] = { nounwind }