Files
clang-p2996/llvm/test/CodeGen/X86/semantic-interposition-comdat.ll
Ben Dunbobbin 4cb016cd2d [X86][ELF] Prefer lowering MC_GlobalAddress operands to .Lfoo$local for STV_DEFAULT only
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
2020-08-14 00:09:15 +01:00

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}