[all-commits] [llvm/llvm-project] 06f775: [flang] Give internal linkage to internal procedur...

jeanPerier via All-commits all-commits at lists.llvm.org
Wed Feb 28 05:30:42 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 06f775a82f6f562f8de75053f62c9c0dbeaa67d2
      https://github.com/llvm/llvm-project/commit/06f775a82f6f562f8de75053f62c9c0dbeaa67d2
  Author: jeanPerier <jperier at nvidia.com>
  Date:   2024-02-28 (Wed, 28 Feb 2024)

  Changed paths:
    M flang/include/flang/Optimizer/Builder/FIRBuilder.h
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Optimizer/Builder/FIRBuilder.cpp
    M flang/lib/Optimizer/Builder/IntrinsicCall.cpp
    M flang/test/Lower/HLFIR/allocatable-end-of-scope-dealloc.f90
    M flang/test/Lower/HLFIR/bindc_internal_proc.f90
    M flang/test/Lower/HLFIR/internal-procedures-2.f90
    M flang/test/Lower/HLFIR/internal-procedures.f90
    M flang/test/Lower/Intrinsics/random.f90
    M flang/test/Lower/Intrinsics/ubound01.f90
    M flang/test/Lower/OpenACC/acc-routine04.f90
    M flang/test/Lower/OpenMP/FIR/threadprivate-use-association-2.f90
    M flang/test/Lower/OpenMP/threadprivate-commonblock-use.f90
    M flang/test/Lower/OpenMP/threadprivate-use-association-2-hlfir.f90
    M flang/test/Lower/PowerPC/ppc-vector-types.f90
    M flang/test/Lower/array-temp.f90
    M flang/test/Lower/dummy-arguments.f90
    M flang/test/Lower/dummy-procedure-character.f90
    M flang/test/Lower/equivalence-with-host-assoc.f90
    M flang/test/Lower/explicit-interface-results-2.f90
    M flang/test/Lower/forall/array-constructor.f90
    M flang/test/Lower/forall/character-1.f90
    M flang/test/Lower/global-initialization.f90
    M flang/test/Lower/host-associated-functions.f90
    M flang/test/Lower/host-associated-globals.f90
    M flang/test/Lower/host-associated.f90
    M flang/test/Lower/module-and-internal-proc.f90
    M flang/test/Lower/parent-component.f90
    M flang/test/Lower/polymorphic.f90
    M flang/test/Lower/program-units-fir-mangling.f90

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list