[LTO] Record whether LTOUnit splitting is enabled in index
Summary:
Records in the module summary index whether the bitcode was compiled
with the option necessary to enable splitting the LTO unit
(e.g. -fsanitize=cfi, -fwhole-program-vtables, or -fsplit-lto-unit).
The information is passed down to the ModuleSummaryIndex builder via a
new module flag "EnableSplitLTOUnit", which is propagated onto a flag
on the summary index.
This is then used during the LTO link to check whether all linked
summaries were built with the same value of this flag. If not, an error
is issued when we detect a situation requiring whole program visibility
of the class hierarchy. This is the case when both of the following
conditions are met:
1) We are performing LowerTypeTests or Whole Program Devirtualization.
2) There are type tests or type checked loads in the code.
Note I have also changed the ThinLTOBitcodeWriter to also gate the
module splitting on the value of this flag.
Reviewers: pcc
Subscribers: ormris, mehdi_amini, Prazek, inglorion, eraman, steven_wu, dexonsmith, arphaman, dang, llvm-commits
Differential Revision: https://reviews.llvm.org/D53890
llvm-svn: 350948
2019-01-12 02:31:57 +08:00
|
|
|
; RUN: opt -thinlto-bc -thinlto-split-lto-unit %s -o %t1.bc
|
2017-06-16 08:18:29 +08:00
|
|
|
; RUN: llvm-lto2 run -thinlto-distributed-indexes %t1.bc -o %t.out -save-temps \
|
|
|
|
; RUN: -r %t1.bc,foo,plx \
|
[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
|
|
|
; RUN: -r %t1.bc,bar,x \
|
|
|
|
; RUN: -r %t1.bc,addrtaken,px
|
2017-06-16 08:18:29 +08:00
|
|
|
; RUN: llvm-bcanalyzer -dump %t.out.index.bc | FileCheck %s --check-prefix=COMBINED
|
|
|
|
|
2019-09-11 07:15:38 +08:00
|
|
|
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
2017-06-16 08:18:29 +08:00
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
define i1 @foo(i8* %p) !type !0 {
|
|
|
|
entry:
|
|
|
|
%x = call i1 @llvm.type.test(i8* %p, metadata !"typeid1")
|
|
|
|
ret i1 %x
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
declare !type !0 i1 @bar(i8*)
|
|
|
|
|
|
|
|
; Functions must be address taken to have jump table entries emitted
|
|
|
|
define void @addrtaken(i1 %i) {
|
|
|
|
%1 = select i1 %i, i1(i8*)* @foo, i1(i8*)* @bar
|
|
|
|
ret void
|
|
|
|
}
|
2017-06-16 08:18:29 +08:00
|
|
|
|
|
|
|
declare i1 @llvm.type.test(i8* %ptr, metadata %type) nounwind readnone
|
|
|
|
|
|
|
|
!0 = !{i64 0, !"typeid1"}
|
|
|
|
|
|
|
|
; COMBINED: <GLOBALVAL_SUMMARY_BLOCK
|
|
|
|
; COMBINED: <CFI_FUNCTION_DEFS op0=0 op1=3/>
|
|
|
|
; COMBINED: <CFI_FUNCTION_DECLS op0=3 op1=3/>
|
2018-02-15 06:41:15 +08:00
|
|
|
; COMBINED: <TYPE_ID op0=6 op1=7 op2=4 op3=7 op4=0 op5=0 op6=0 op7=0/>
|
2017-06-16 08:18:29 +08:00
|
|
|
; COMBINED: </GLOBALVAL_SUMMARY_BLOCK>
|
|
|
|
|
|
|
|
; COMBINED: <STRTAB_BLOCK
|
2018-02-15 06:41:15 +08:00
|
|
|
; COMBINED-NEXT: <BLOB abbrevid=4/> blob data = 'foobartypeid1'
|
2017-06-16 08:18:29 +08:00
|
|
|
; COMBINED-NEXT: </STRTAB_BLOCK>
|