This patch restricts the behaviour of referencing via .Lfoo$local local aliases, introduced in https://reviews.llvm.org/D73230, to STV_DEFAULT globals only. Hidden symbols via --fvisiblity=hidden (https://gcc.gnu.org/wiki/Visibility) is an important scenario. Benefits: - Improves the size of object files by using fewer STT_SECTION symbols. - The code reads a bit better (it was not obvious to me without going back to the code reviews why the canBenefitFromLocalAlias function currently doesn't consider visibility). - There is also a side benefit in restoring the effectiveness of the --wrap linker option and making the behavior of --wrap consistent between LTO and normal builds for references within a translation-unit. Note: this --wrap behavior (which is specific to LLD) should not be considered reliable. See comments on https://reviews.llvm.org/D73230 for more. Differential Revision: https://reviews.llvm.org/D85782
29 lines
494 B
LLVM
29 lines
494 B
LLVM
; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s
|
|
|
|
$comdat_func = comdat any
|
|
|
|
; CHECK-LABEL: func2:
|
|
; CHECK-NOT: .Lfunc2$local
|
|
|
|
declare void @func()
|
|
|
|
define hidden void @func2() {
|
|
entry:
|
|
call void @func()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: comdat_func:
|
|
; CHECK-NOT: .Lcomdat_func$local
|
|
|
|
define hidden void @comdat_func() comdat {
|
|
entry:
|
|
call void @func()
|
|
ret void
|
|
}
|
|
|
|
!llvm.module.flags = !{!0, !1}
|
|
|
|
!0 = !{i32 1, !"SemanticInterposition", i32 0}
|
|
!1 = !{i32 7, !"PIC Level", i32 2}
|