Files
clang-p2996/flang/test/Lower/OpenMP/threadprivate-commonblock-use.f90
jeanPerier 06f775a82f [flang] Give internal linkage to internal procedures (#81929)
Internal procedures cannot be called directly from outside the host
procedure, so there is no point giving them external linkage. The only
reason flang did is because it is the default in MLIR.

Giving external linkage to them:
- prevents deleting them when not used/inlined by LLVM
- causes bugs with shared libraries (at least on linux x86-64) because
the call to the internal function could lead to a dynamic loader call
that would overwrite r10 register (the static chain pointer) due to
system calls and did not restore (it seems it does not expect r10 to be
used for PLT calls).

This patch gives internal linkage to internal procedures:

Note: the llvm.linkage attribute name cannot be obtained via a
getLinkageAttrName since it is not the same name as the one used in the
LLVM dialect. It is just a placeholder defined in
mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp until the func dialect
gets a real linkage model. So simply avoid hard coding it too many times
in lowering.
2024-02-28 14:30:29 +01:00

30 lines
821 B
Fortran

! This test checks lowering of OpenMP Threadprivate Directive.
! Test for common block, defined in one module, used in a subroutine of
! another module and privatized in a nested subroutine.
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK: fir.global common @cmn_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
module m0
common /cmn/ k1
!$omp threadprivate(/cmn/)
end
module m1
contains
subroutine ss1
use m0
contains
!CHECK-LABEL: func private @_QMm1Fss1Pss2
!CHECK: %[[CMN:.*]] = fir.address_of(@cmn_) : !fir.ref<!fir.array<4xi8>>
!CHECK: omp.parallel
!CHECK: %{{.*}} = omp.threadprivate %[[CMN]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>
subroutine ss2
!$omp parallel copyin (k1)
!$omp end parallel
end subroutine ss2
end subroutine ss1
end
end