[flang-commits] [clang] [flang] [llvm] [flang] Add runtime trampoline pool for W^X compliance (PR #183108)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Sun Mar 1 06:48:45 PST 2026
================
@@ -0,0 +1,41 @@
+! RUN: %flang -fsafe-trampoline -emit-llvm -S -o - %s | FileCheck %s
+!
+! Test that -fsafe-trampoline generates calls to the runtime
+! trampoline pool instead of stack-based trampolines.
+
+! 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
+end module other
+
+subroutine host(local)
+ use other
+ integer :: local
+ procedure(callback), pointer :: fptr
+ fptr => callee
+ call foo(fptr)
----------------
eugeneepshteyn wrote:
Please also add test cases where trampolines are not just used at the top level block of procedure, but also used inside `if` or `do` loop.
https://github.com/llvm/llvm-project/pull/183108
More information about the flang-commits
mailing list