
Inline assembly refererences to static functions with ThinLTO+CFI were fixed in D104058 by creating aliases for promoted functions. Creating the aliases unconditionally resulted in an unexpected size increase in a Chrome helper binary: https://bugs.chromium.org/p/chromium/issues/detail?id=1261715 This is caused by the compiler being unable to drop unused code now referenced by the alias in module-level inline assembly. This change adds a .set_conditional assembly extension, which emits an assignment only if the target symbol is also emitted, avoiding phantom references to functions that could have otherwise been dropped. This is an alternative to the solution proposed in D112761. Reviewed By: pcc, nickdesaulniers, MaskRay Differential Revision: https://reviews.llvm.org/D113613
23 lines
692 B
LLVM
23 lines
692 B
LLVM
; REQUIRES: x86-registered-target
|
|
; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o - %s | llvm-modextract -b -n 0 -o - | llvm-dis | FileCheck %s
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
; CHECK: module asm ".lto_set_conditional a,a.[[HASH:[0-9a-f]+]]"
|
|
|
|
define void @b() {
|
|
%f = alloca void ()*, align 8
|
|
; CHECK: store{{.*}} @a.[[HASH]],{{.*}} %f
|
|
store void ()* @a, void ()** %f, align 8
|
|
; CHECK: %1 = call void ()* asm sideeffect "leaq a(%rip)
|
|
%1 = call void ()* asm sideeffect "leaq a(%rip), $0\0A\09", "=r,~{dirflag},~{fpsr},~{flags}"()
|
|
ret void
|
|
}
|
|
|
|
; CHECK: define{{.*}} @a.[[HASH]](){{.*}} !type
|
|
define internal void @a() !type !0 {
|
|
ret void
|
|
}
|
|
|
|
!0 = !{i64 0, !"typeid1"}
|