Files
TheRock/compiler/amd-llvm/flang/test/Lower/safe-trampoline.f90
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

127 lines
2.9 KiB
Fortran

! RUN: %flang_fc1 -fsafe-trampoline -emit-llvm -o - %s | FileCheck %s
!
! Test that -fsafe-trampoline generates calls to the runtime
! trampoline pool instead of stack-based trampolines.
!
! Test cases cover trampolines at the top-level block, used inside an IF block,
! and used inside a DO loop.
! CHECK-LABEL: define {{.*}}@host_
! CHECK: call {{.*}}@_FortranATrampolineInit
! CHECK: call {{.*}}@_FortranATrampolineAdjust
! CHECK: call {{.*}}@_FortranATrampolineFree
! CHECK-LABEL: define {{.*}}@host_in_if_
! CHECK: call {{.*}}@_FortranATrampolineInit
! CHECK: call {{.*}}@_FortranATrampolineAdjust
! CHECK: call {{.*}}@_FortranATrampolineFree
! CHECK-LABEL: define {{.*}}@host_in_do_loop_
! CHECK: call {{.*}}@_FortranATrampolineInit
! CHECK: call {{.*}}@_FortranATrampolineAdjust
! CHECK: call {{.*}}@_FortranATrampolineFree
! CHECK-LABEL: define {{.*}}@host_branch_
! CHECK: call {{.*}}@_FortranATrampolineInit
! CHECK: call {{.*}}@_FortranATrampolineAdjust
! CHECK: call {{.*}}@_FortranATrampolineFree
module other
abstract interface
function callback()
integer :: callback
end function callback
end interface
contains
subroutine foo(fptr)
procedure(callback), pointer :: fptr
print *, fptr()
end subroutine foo
subroutine bar(fproc)
procedure(callback) :: fproc
print *, fproc()
end subroutine bar
end module other
! Test 1: trampoline at top-level block (baseline).
subroutine host(local)
use other
integer :: local
procedure(callback), pointer :: fptr
fptr => callee
call foo(fptr)
return
contains
function callee()
integer :: callee
callee = local
end function callee
end subroutine host
! Test 2: trampoline used inside an IF block.
subroutine host_in_if(local, flag)
use other
integer :: local
logical :: flag
procedure(callback), pointer :: fptr
fptr => callee
if (flag) then
call foo(fptr)
end if
return
contains
function callee()
integer :: callee
callee = local
end function callee
end subroutine host_in_if
! Test 3: trampoline used inside a DO loop.
subroutine host_in_do_loop(local, n)
use other
integer :: local
integer :: n
integer :: i
procedure(callback), pointer :: fptr
fptr => callee
do i = 1, n
call foo(fptr)
end do
return
contains
function callee()
integer :: callee
callee = local + i
end function callee
end subroutine host_in_do_loop
! Test 4: emboxproc generated inside a branch (internal procedure passed
! directly as actual argument inside an IF block).
subroutine host_branch(local, flag)
use other
integer :: local
logical :: flag
if (flag) call bar(callee)
return
contains
function callee()
integer :: callee
callee = local
end function callee
end subroutine host_branch
program main
call host(10)
call host_in_if(20, .true.)
call host_in_do_loop(30, 3)
call host_branch(40, .true.)
end program main