llvm-project/llvm/test/LTO/Resolution/X86/export-jumptable.ll

33 lines
898 B
LLVM
Raw Normal View History

; Test that we do not internalize functions that appear in the CFI jump table in
; the full LTO object file; any such functions will be referenced by the jump
; table.
; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
; RUN: llvm-lto2 run -o %t2 -r %t,f1,p -r %t,f2,p -r %t,_start,px %t -save-temps
; RUN: llvm-dis %t2.1.2.internalize.bc -o - | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK: define void @f1()
define void @f1() !type !0 {
ret void
}
; CHECK: define internal void @f2()
define void @f2() !type !1 {
ret void
}
[LowerTypeTests] Limit when icall jumptable entries are emitted Summary: Currently LowerTypeTests emits jumptable entries for all live external and address-taken functions; however, we could limit the number of functions that we emit entries for significantly. For Cross-DSO CFI, we continue to emit jumptable entries for all exported definitions. In the non-Cross-DSO CFI case, we only need to emit jumptable entries for live functions that are address-taken in live functions. This ignores exported functions and functions that are only address taken in dead functions. This change uses ThinLTO summary data (now emitted for all modules during ThinLTO builds) to determine address-taken and liveness info. The logic for emitting jumptable entries is more conservative in the regular LTO case because we don't have summary data in the case of monolithic LTO builds; however, once summaries are emitted for all LTO builds we can unify the Thin/monolithic LTO logic to only use summaries to determine the liveness of address taking functions. This change is a partial fix for PR37474. It reduces the build size for nacl_helper by ~2-3%, the reduction is due to nacl_helper compiling in lots of unused code and unused functions that are address taken in dead functions no longer being being considered live due to emitted jumptable references. The reduction for chromium is ~0.1-0.2%. Reviewers: pcc, eugenis, javed.absar Reviewed By: pcc Subscribers: aheejin, dexonsmith, dschuff, mehdi_amini, eraman, steven_wu, llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D47652 llvm-svn: 337038
2018-07-14 03:57:39 +08:00
define i1 @_start(i1 %i) {
%1 = select i1 %i, void ()* @f1, void ()* @f2
%2 = bitcast void ()* %1 to i8*
%3 = call i1 @llvm.type.test(i8* %2, metadata !"typeid1")
ret i1 %3
}
declare i1 @llvm.type.test(i8*, metadata)
!0 = !{i64 0, !"typeid1"}
!1 = !{i64 0, !"typeid2"}