Skip to content

Commit 06f775a

Browse files
authored
[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.
1 parent 915fce0 commit 06f775a

30 files changed

+140
-120
lines changed

flang/include/flang/Optimizer/Builder/FIRBuilder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,9 @@ fir::BoxValue createBoxValue(fir::FirOpBuilder &builder, mlir::Location loc,
688688
/// Generate Null BoxProc for procedure pointer null initialization.
689689
mlir::Value createNullBoxProc(fir::FirOpBuilder &builder, mlir::Location loc,
690690
mlir::Type boxType);
691+
692+
/// Set internal linkage attribute on a function.
693+
void setInternalLinkage(mlir::func::FuncOp);
691694
} // namespace fir::factory
692695

693696
#endif // FORTRAN_OPTIMIZER_BUILDER_FIRBUILDER_H

flang/lib/Lower/Bridge.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4488,7 +4488,16 @@ class FirConverter : public Fortran::lower::AbstractConverter {
44884488
assert(builder && "FirOpBuilder did not instantiate");
44894489
builder->setFastMathFlags(bridge.getLoweringOptions().getMathOptions());
44904490
builder->setInsertionPointToStart(&func.front());
4491-
func.setVisibility(mlir::SymbolTable::Visibility::Public);
4491+
if (funit.parent.isA<Fortran::lower::pft::FunctionLikeUnit>()) {
4492+
// Give internal linkage to internal functions. There are no name clash
4493+
// risks, but giving global linkage to internal procedure will break the
4494+
// static link register in shared libraries because of the system calls.
4495+
// Also, it should be possible to eliminate the procedure code if all the
4496+
// uses have been inlined.
4497+
fir::factory::setInternalLinkage(func);
4498+
} else {
4499+
func.setVisibility(mlir::SymbolTable::Visibility::Public);
4500+
}
44924501
assert(blockId == 0 && "invalid blockId");
44934502
assert(activeConstructStack.empty() && "invalid construct stack state");
44944503

flang/lib/Optimizer/Builder/FIRBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
1919
#include "flang/Optimizer/Support/FatalError.h"
2020
#include "flang/Optimizer/Support/InternalNames.h"
21+
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
2122
#include "mlir/Dialect/OpenACC/OpenACC.h"
2223
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
2324
#include "llvm/ADT/ArrayRef.h"
@@ -1533,3 +1534,10 @@ mlir::Value fir::factory::createNullBoxProc(fir::FirOpBuilder &builder,
15331534
mlir::Value initVal{builder.create<fir::ZeroOp>(loc, boxEleTy)};
15341535
return builder.create<fir::EmboxProcOp>(loc, boxTy, initVal);
15351536
}
1537+
1538+
void fir::factory::setInternalLinkage(mlir::func::FuncOp func) {
1539+
auto internalLinkage = mlir::LLVM::linkage::Linkage::Internal;
1540+
auto linkage =
1541+
mlir::LLVM::LinkageAttr::get(func->getContext(), internalLinkage);
1542+
func->setAttr("llvm.linkage", linkage);
1543+
}

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,10 +1834,7 @@ mlir::func::FuncOp IntrinsicLibrary::getWrapper(GeneratorType generator,
18341834
// First time this wrapper is needed, build it.
18351835
function = builder.createFunction(loc, wrapperName, funcType);
18361836
function->setAttr("fir.intrinsic", builder.getUnitAttr());
1837-
auto internalLinkage = mlir::LLVM::linkage::Linkage::Internal;
1838-
auto linkage =
1839-
mlir::LLVM::LinkageAttr::get(builder.getContext(), internalLinkage);
1840-
function->setAttr("llvm.linkage", linkage);
1837+
fir::factory::setInternalLinkage(function);
18411838
function.addEntryBlock();
18421839

18431840
// Create local context to emit code into the newly created function

flang/test/Lower/HLFIR/allocatable-end-of-scope-dealloc.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ subroutine internal()
224224
allocate(x)
225225
end subroutine
226226
end subroutine
227-
! CHECK-LABEL: func.func @_QFno_dealloc_host_assocPinternal
227+
! CHECK-LABEL: func.func private @_QFno_dealloc_host_assocPinternal
228228
! CHECK-NOT: freemem
229229
! CHECK-NOT: Deallocate
230230
! CHECK: return

flang/test/Lower/HLFIR/bindc_internal_proc.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
! internal procedures.
44
! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
55

6-
!CHECK: func.func @_QFsub1Pfoo(%{{.*}}: i32
6+
!CHECK: func.func private @_QFsub1Pfoo(%{{.*}}: i32
77
subroutine sub1()
88
call foo(42)
99
contains
@@ -13,7 +13,7 @@ subroutine foo(i) bind(c)
1313
end subroutine
1414
end subroutine
1515

16-
!CHECK: func.func @_QFsub2Pfoo(%{{.*}}: i64
16+
!CHECK: func.func private @_QFsub2Pfoo(%{{.*}}: i64
1717
subroutine sub2()
1818
call foo(42_8)
1919
contains

flang/test/Lower/HLFIR/internal-procedures-2.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ subroutine internal_procedure(i, mask)
2323
end forall
2424
end subroutine
2525
end subroutine
26-
! CHECK-LABEL: func.func @_QFhost_procedurePinternal_procedure(
26+
! CHECK-LABEL: func.func private @_QFhost_procedurePinternal_procedure(
2727
! CHECK: fir.address_of(@_QMmodule_used_by_hostEindexed_by_var) : !fir.ref<!fir.array<2xi32>>
2828
! CHECK: fir.address_of(@_QMmodule_used_by_hostEref_in_forall) : !fir.ref<!fir.array<2xi32>>
2929
! CHECK: fir.address_of(@_QMmodule_used_by_hostEref_in_implied_do) : !fir.ref<i32>

flang/test/Lower/HLFIR/internal-procedures.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ subroutine internal
99
call takes_array(x)
1010
end subroutine
1111
end subroutine
12-
! CHECK-LABEL: func.func @_QFtest_explicit_shape_arrayPinternal(
13-
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.box<!fir.array<?xf32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
12+
! CHECK-LABEL: func.func private @_QFtest_explicit_shape_arrayPinternal(
13+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.box<!fir.array<?xf32>>>> {fir.host_assoc}) attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
1414
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
1515
! CHECK: %[[VAL_2:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_1]] : (!fir.ref<tuple<!fir.box<!fir.array<?xf32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<?xf32>>>
1616
! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.array<?xf32>>>
@@ -27,8 +27,8 @@ subroutine internal
2727
call takes_array(x)
2828
end subroutine
2929
end subroutine
30-
! CHECK-LABEL: func.func @_QFtest_assumed_shapePinternal(
31-
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.box<!fir.array<?xf32>>>> {fir.host_assoc}) attributes {fir.internal_proc} {
30+
! CHECK-LABEL: func.func private @_QFtest_assumed_shapePinternal(
31+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.box<!fir.array<?xf32>>>> {fir.host_assoc}) attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
3232
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
3333
! CHECK: %[[VAL_2:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_1]] : (!fir.ref<tuple<!fir.box<!fir.array<?xf32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<?xf32>>>
3434
! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.array<?xf32>>>
@@ -44,8 +44,8 @@ subroutine internal()
4444
call bar(c)
4545
end subroutine
4646
end subroutine
47-
! CHECK-LABEL: func.func @_QFtest_scalar_charPinternal(
48-
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.boxchar<1>>> {fir.host_assoc}) attributes {fir.internal_proc} {
47+
! CHECK-LABEL: func.func private @_QFtest_scalar_charPinternal(
48+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.boxchar<1>>> {fir.host_assoc}) attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
4949
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
5050
! CHECK: %[[VAL_2:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_1]] : (!fir.ref<tuple<!fir.boxchar<1>>>, i32) -> !fir.ref<!fir.boxchar<1>>
5151
! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.boxchar<1>>

flang/test/Lower/Intrinsics/random.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ subroutine random_test_2
4545
call foo(size)
4646
call bar(size, get)
4747
contains
48-
! CHECK-LABEL: func @_QFrandom_test_2Pfoo
48+
! CHECK-LABEL: func private @_QFrandom_test_2Pfoo
4949
subroutine foo(size, put, get)
5050
! CHECK: [[s1:%[0-9]+]] = fir.is_present %arg0
5151
! CHECK: [[s2:%[0-9]+]] = fir.embox %arg0
@@ -70,7 +70,7 @@ subroutine foo(size, put, get)
7070
print*, size
7171
end subroutine
7272

73-
! CHECK-LABEL: func @_QFrandom_test_2Pbar
73+
! CHECK-LABEL: func private @_QFrandom_test_2Pbar
7474
subroutine bar(size, get, put)
7575
integer, optional :: size
7676
! CHECK: [[p1:%[0-9]+]] = fir.is_present %arg2

flang/test/Lower/Intrinsics/ubound01.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ subroutine s2(a,n,n2)
1616
End Subroutine
1717
end
1818

19-
! CHECK-LABEL: func.func @_QFPs2
19+
! CHECK-LABEL: func.func private @_QFPs2
2020
! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?x?xf32>>
2121
! CHECK: %[[BOX:.*]] = fir.rebox %[[ARG0]](%{{.*}}) : (!fir.box<!fir.array<?x?xf32>>, !fir.shift<2>) -> !fir.box<!fir.array<?x?xf32>>
2222
! CHECK: %[[BOX_NONE:.*]] = fir.convert %[[BOX]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.box<none>

flang/test/Lower/OpenACC/acc-routine04.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ subroutine sub2()
3131
! CHECK: acc.routine @acc_routine_0 func(@_QMdummy_modPsub1) seq
3232
! CHECK: func.func @_QMdummy_modPsub1(%arg0: !fir.ref<i32> {fir.bindc_name = "i"}) attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}
3333
! CHECK: func.func @_QQmain() attributes {fir.bindc_name = "test_acc_routine"}
34-
! CHECK: func.func @_QFPsub2() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_1]>}
34+
! CHECK: func.func private @_QFPsub2() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_1]>, llvm.linkage = #llvm.linkage<internal>}

flang/test/Lower/OpenMP/FIR/threadprivate-use-association-2.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module m
1717
! CHECK: return
1818
! CHECK: }
1919
!
20-
! CHECK-LABEL: func.func @_QMm2FtestPinternal_test() {
20+
! CHECK-LABEL: func.func private @_QMm2FtestPinternal_test() {{.*}} {
2121
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMmEx) : !fir.ref<i32>
2222
! CHECK: %[[VAL_1:.*]] = omp.threadprivate %[[VAL_0]] : !fir.ref<i32> -> !fir.ref<i32>
2323
! CHECK: fir.call @_QPbar(%[[VAL_1]]) {{.*}}: (!fir.ref<i32>) -> ()

flang/test/Lower/OpenMP/threadprivate-commonblock-use.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module m1
1515
subroutine ss1
1616
use m0
1717
contains
18-
!CHECK-LABEL: func @_QMm1Fss1Pss2
18+
!CHECK-LABEL: func private @_QMm1Fss1Pss2
1919
!CHECK: %[[CMN:.*]] = fir.address_of(@cmn_) : !fir.ref<!fir.array<4xi8>>
2020
!CHECK: omp.parallel
2121
!CHECK: %{{.*}} = omp.threadprivate %[[CMN]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>

flang/test/Lower/OpenMP/threadprivate-use-association-2-hlfir.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module m
1919
! CHECK: return
2020
! CHECK: }
2121

22-
! CHECK-LABEL: func.func @_QMm2FtestPinternal_test() {
22+
! CHECK-LABEL: func.func private @_QMm2FtestPinternal_test() {{.*}} {
2323
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMmEx) : !fir.ref<i32>
2424
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QMmEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
2525
! CHECK: %[[VAL_2:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32>

flang/test/Lower/PowerPC/ppc-vector-types.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ program ppc_vec_unit
4444
! CHECK-LLVM-NEXT: store <512 x i1> %[[RESQ]], ptr @_QFEvq2, align 64
4545

4646
contains
47-
! CHECK-LLVM-LABEL: define <4 x i32> @_QFPtest_vec_integer_assign
47+
! CHECK-LLVM-LABEL: define internal <4 x i32> @_QFPtest_vec_integer_assign
4848
function test_vec_integer_assign(arg1)
4949
! CHECK-LLVM: %[[FUNC_RES:.*]] = alloca <4 x i32>, i64 1, align 16
5050
vector(integer(4)) :: arg1, test_vec_integer_assign
@@ -58,7 +58,7 @@ function test_vec_integer_assign(arg1)
5858
! CHECK-LLVM-NEXT: ret <4 x i32> %[[RET]]
5959
end function test_vec_integer_assign
6060

61-
! CHECK-LLVM-LABEL: define <2 x double> @_QFPtest_vec_real_assign
61+
! CHECK-LLVM-LABEL: define internal <2 x double> @_QFPtest_vec_real_assign
6262
function test_vec_real_assign(arg1)
6363
! CHECK-LLVM: %[[FUNC_RES:.*]] = alloca <2 x double>, i64 1, align 16
6464
vector(real(8)) :: arg1, test_vec_real_assign
@@ -72,7 +72,7 @@ function test_vec_real_assign(arg1)
7272
! CHECK-LLVM-NEXT: ret <2 x double> %[[RET]]
7373
end function test_vec_real_assign
7474

75-
! CHECK-LLVM-LABEL: define <8 x i16> @_QFPtest_vec_unsigned_assign
75+
! CHECK-LLVM-LABEL: define internal <8 x i16> @_QFPtest_vec_unsigned_assign
7676
function test_vec_unsigned_assign(arg1)
7777
! CHECK-LLVM: %[[FUNC_RES:.*]] = alloca <8 x i16>, i64 1, align 16
7878
vector(unsigned(2)) :: arg1, test_vec_unsigned_assign
@@ -86,7 +86,7 @@ function test_vec_unsigned_assign(arg1)
8686
! CHECK-LLVM-NEXT: ret <8 x i16> %[[RET]]
8787
end function test_vec_unsigned_assign
8888

89-
! CHECK-LLVM-LABEL: define <256 x i1> @_QFPtest_vec_pair_assign
89+
! CHECK-LLVM-LABEL: define internal <256 x i1> @_QFPtest_vec_pair_assign
9090
function test_vec_pair_assign(arg1)
9191
! CHECK-LLVM: %[[FUNC_RES:.*]] = alloca <256 x i1>, i64 1, align 32
9292
__vector_pair :: arg1, test_vec_pair_assign
@@ -100,7 +100,7 @@ function test_vec_pair_assign(arg1)
100100
! CHECK-LLVM-NEXT: ret <256 x i1> %[[RET]]
101101
end function test_vec_pair_assign
102102

103-
! CHECK-LLVM-LABEL: define <512 x i1> @_QFPtest_vec_quad_assign
103+
! CHECK-LLVM-LABEL: define internal <512 x i1> @_QFPtest_vec_quad_assign
104104
function test_vec_quad_assign(arg1)
105105
! CHECK-LLVM: %[[FUNC_RES:.*]] = alloca <512 x i1>, i64 1, align 64
106106
__vector_quad :: arg1, test_vec_quad_assign

flang/test/Lower/array-temp.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ subroutine tt1
404404
! CHECK-NEXT: fir.call @_FortranAioEndIoStatement
405405
print*, [(r([7.0]),i=1,3)]
406406
contains
407-
! CHECK-LABEL: func @_QFtt1Pr
407+
! CHECK-LABEL: func private @_QFtt1Pr
408408
function r(x)
409409
real x(:)
410410
r = x(1)

flang/test/Lower/dummy-arguments.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ program test1
99
call foo(10)
1010
contains
1111

12-
! CHECK-LABEL: func @_QFPfoo
12+
! CHECK-LABEL: func private @_QFPfoo
1313
subroutine foo(avar1)
1414
integer :: avar1
1515
! integer :: my_data, my_data2

flang/test/Lower/dummy-procedure-character.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ subroutine host(f)
213213
! CHECK: fir.call @_QFhostPintern(%[[VAL_1]])
214214
call intern()
215215
contains
216-
! CHECK-LABEL: func @_QFhostPintern(
216+
! CHECK-LABEL: func private @_QFhostPintern(
217217
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<tuple<!fir.boxproc<() -> ()>, i64>>> {fir.host_assoc})
218218
subroutine intern()
219219
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
@@ -242,7 +242,7 @@ subroutine host2(f)
242242
! CHECK: fir.call @_QFhost2Pintern(%[[VAL_1]])
243243
call intern()
244244
contains
245-
! CHECK-LABEL: func @_QFhost2Pintern(
245+
! CHECK-LABEL: func private @_QFhost2Pintern(
246246
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<tuple<!fir.boxproc<() -> ()>, i64>>> {fir.host_assoc})
247247
subroutine intern()
248248
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.char<1,42> {bindc_name = ".result"}

flang/test/Lower/equivalence-with-host-assoc.f90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ subroutine inner
1010
i1 = j1
1111
end subroutine inner
1212
end subroutine test1
13-
! FIR-LABEL: func.func @_QFtest1Pinner() attributes {fir.internal_proc} {
13+
! FIR-LABEL: func.func private @_QFtest1Pinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
1414
! FIR: %[[VAL_0:.*]] = fir.address_of(@_QFtest1Ei1) : !fir.ref<!fir.array<1xi32>>
1515
! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.array<1xi32>>) -> !fir.ref<!fir.array<4xi8>>
1616
! FIR: %[[VAL_2:.*]] = arith.constant 0 : index
@@ -24,7 +24,7 @@ end subroutine test1
2424
! FIR: return
2525
! FIR: }
2626

27-
! HLFIR-LABEL: func.func @_QFtest1Pinner() attributes {fir.internal_proc} {
27+
! HLFIR-LABEL: func.func private @_QFtest1Pinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
2828
! HLFIR: %[[VAL_0:.*]] = fir.address_of(@_QFtest1Ei1) : !fir.ref<!fir.array<1xi32>>
2929
! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.array<1xi32>>) -> !fir.ref<!fir.array<4xi8>>
3030
! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index
@@ -54,7 +54,7 @@ subroutine inner
5454
end subroutine inner
5555
end subroutine host
5656
end module test2
57-
! FIR-LABEL: func.func @_QMtest2FhostPinner() attributes {fir.internal_proc} {
57+
! FIR-LABEL: func.func private @_QMtest2FhostPinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
5858
! FIR: %[[VAL_0:.*]] = fir.address_of(@_QMtest2FhostEf1) : !fir.ref<!fir.array<1xi32>>
5959
! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.array<1xi32>>) -> !fir.ref<!fir.array<4xi8>>
6060
! FIR: %[[VAL_2:.*]] = arith.constant 0 : index
@@ -68,7 +68,7 @@ end module test2
6868
! FIR: return
6969
! FIR: }
7070

71-
! HLFIR-LABEL: func.func @_QMtest2FhostPinner() attributes {fir.internal_proc} {
71+
! HLFIR-LABEL: func.func private @_QMtest2FhostPinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
7272
! HLFIR: %[[VAL_0:.*]] = fir.address_of(@_QMtest2FhostEf1) : !fir.ref<!fir.array<1xi32>>
7373
! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.array<1xi32>>) -> !fir.ref<!fir.array<4xi8>>
7474
! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index
@@ -94,7 +94,7 @@ subroutine inner
9494
i1 = j1 + k1
9595
end subroutine inner
9696
end subroutine test3
97-
! FIR-LABEL: func.func @_QFtest3Pinner() attributes {fir.internal_proc} {
97+
! FIR-LABEL: func.func private @_QFtest3Pinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
9898
! FIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref<tuple<i32>>
9999
! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<tuple<i32>>) -> !fir.ref<!fir.array<?xi8>>
100100
! FIR: %[[VAL_2:.*]] = arith.constant 0 : index
@@ -115,7 +115,7 @@ end subroutine test3
115115
! FIR: return
116116
! FIR: }
117117

118-
! HLFIR-LABEL: func.func @_QFtest3Pinner() attributes {fir.internal_proc} {
118+
! HLFIR-LABEL: func.func private @_QFtest3Pinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
119119
! HLFIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref<tuple<i32>>
120120
! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<tuple<i32>>) -> !fir.ref<!fir.array<?xi8>>
121121
! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index
@@ -149,7 +149,7 @@ subroutine inner
149149
i1 = j1 + k1
150150
end subroutine inner
151151
end subroutine test4
152-
! FIR-LABEL: func.func @_QFtest4Pinner() attributes {fir.internal_proc} {
152+
! FIR-LABEL: func.func private @_QFtest4Pinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
153153
! FIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref<tuple<i32>>
154154
! FIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<tuple<i32>>) -> !fir.ref<!fir.array<?xi8>>
155155
! FIR: %[[VAL_2:.*]] = arith.constant 0 : index
@@ -170,7 +170,7 @@ end subroutine test4
170170
! FIR: return
171171
! FIR: }
172172

173-
! HLFIR-LABEL: func.func @_QFtest4Pinner() attributes {fir.internal_proc} {
173+
! HLFIR-LABEL: func.func private @_QFtest4Pinner() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
174174
! HLFIR: %[[VAL_0:.*]] = fir.address_of(@blk_) : !fir.ref<tuple<i32>>
175175
! HLFIR: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<tuple<i32>>) -> !fir.ref<!fir.array<?xi8>>
176176
! HLFIR: %[[VAL_2:.*]] = arith.constant 0 : index

flang/test/Lower/explicit-interface-results-2.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ subroutine host4()
6969
integer :: n
7070
call internal_proc_a()
7171
contains
72-
! CHECK-LABEL: func @_QFhost4Pinternal_proc_a
73-
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.ref<i32>>> {fir.host_assoc}) attributes {fir.internal_proc} {
72+
! CHECK-LABEL: func private @_QFhost4Pinternal_proc_a
73+
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.ref<i32>>> {fir.host_assoc}) attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
7474
subroutine internal_proc_a()
7575
call takes_array(return_array())
7676
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
@@ -94,7 +94,7 @@ subroutine host5()
9494
implicit none
9595
call internal_proc_a()
9696
contains
97-
! CHECK-LABEL: func @_QFhost5Pinternal_proc_a() attributes {fir.internal_proc} {
97+
! CHECK-LABEL: func private @_QFhost5Pinternal_proc_a() attributes {fir.internal_proc, llvm.linkage = #llvm.linkage<internal>} {
9898
subroutine internal_proc_a()
9999
call takes_array(return_array())
100100
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMsome_moduleEn_module) : !fir.ref<i32>
@@ -115,7 +115,7 @@ subroutine host6()
115115
implicit none
116116
call internal_proc_a()
117117
contains
118-
! CHECK-LABEL: func @_QFhost6Pinternal_proc_a
118+
! CHECK-LABEL: func private @_QFhost6Pinternal_proc_a
119119
subroutine internal_proc_a()
120120
call takes_array(return_array())
121121
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMsome_moduleEn_module) : !fir.ref<i32>
@@ -187,7 +187,7 @@ subroutine host9()
187187
common /mycom/ n_common
188188
call internal_proc_a()
189189
contains
190-
! CHECK-LABEL: func @_QFhost9Pinternal_proc_a
190+
! CHECK-LABEL: func private @_QFhost9Pinternal_proc_a
191191
subroutine internal_proc_a()
192192
! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index
193193
! CHECK: %[[VAL_1:.*]] = fir.address_of(@mycom_) : !fir.ref<!fir.array<4xi8>>
@@ -213,7 +213,7 @@ subroutine host10()
213213
implicit none
214214
call internal_proc_a()
215215
contains
216-
! CHECK-LABEL: func @_QFhost10Pinternal_proc_a
216+
! CHECK-LABEL: func private @_QFhost10Pinternal_proc_a
217217
subroutine internal_proc_a()
218218
call takes_array(return_array())
219219
! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index

0 commit comments

Comments
 (0)