forked from OSchip/llvm-project
Move summary dead stripping before regular LTO.
This way dead stripping results are recorded in combined summary and can be used in regular LTO passes. Differential Revision: https://reviews.llvm.org/D33615 llvm-svn: 304577
This commit is contained in:
parent
469014ada4
commit
659b3bc77d
|
@ -622,6 +622,19 @@ unsigned LTO::getMaxTasks() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Error LTO::run(AddStreamFn AddStream, NativeObjectCache Cache) {
|
Error LTO::run(AddStreamFn AddStream, NativeObjectCache Cache) {
|
||||||
|
// Compute "dead" symbols, we don't want to import/export these!
|
||||||
|
DenseSet<GlobalValue::GUID> GUIDPreservedSymbols;
|
||||||
|
for (auto &Res : GlobalResolutions) {
|
||||||
|
if (Res.second.VisibleOutsideThinLTO &&
|
||||||
|
// IRName will be defined if we have seen the prevailing copy of
|
||||||
|
// this value. If not, no need to preserve any ThinLTO copies.
|
||||||
|
!Res.second.IRName.empty())
|
||||||
|
GUIDPreservedSymbols.insert(GlobalValue::getGUID(
|
||||||
|
GlobalValue::dropLLVMManglingEscape(Res.second.IRName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
computeDeadSymbols(ThinLTO.CombinedIndex, GUIDPreservedSymbols);
|
||||||
|
|
||||||
// Save the status of having a regularLTO combined module, as
|
// Save the status of having a regularLTO combined module, as
|
||||||
// this is needed for generating the ThinLTO Task ID, and
|
// this is needed for generating the ThinLTO Task ID, and
|
||||||
// the CombinedModule will be moved at the end of runRegularLTO.
|
// the CombinedModule will be moved at the end of runRegularLTO.
|
||||||
|
@ -974,19 +987,6 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
|
||||||
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
|
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
|
||||||
|
|
||||||
if (Conf.OptLevel > 0) {
|
if (Conf.OptLevel > 0) {
|
||||||
// Compute "dead" symbols, we don't want to import/export these!
|
|
||||||
DenseSet<GlobalValue::GUID> GUIDPreservedSymbols;
|
|
||||||
for (auto &Res : GlobalResolutions) {
|
|
||||||
if (Res.second.VisibleOutsideThinLTO &&
|
|
||||||
// IRName will be defined if we have seen the prevailing copy of
|
|
||||||
// this value. If not, no need to preserve any ThinLTO copies.
|
|
||||||
!Res.second.IRName.empty())
|
|
||||||
GUIDPreservedSymbols.insert(GlobalValue::getGUID(
|
|
||||||
GlobalValue::dropLLVMManglingEscape(Res.second.IRName)));
|
|
||||||
}
|
|
||||||
|
|
||||||
computeDeadSymbols(ThinLTO.CombinedIndex, GUIDPreservedSymbols);
|
|
||||||
|
|
||||||
ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
|
ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
|
||||||
ImportLists, ExportLists);
|
ImportLists, ExportLists);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,20 @@
|
||||||
; RUN: llvm-dis < %t.out.1.3.import.bc | FileCheck %s --check-prefix=CHECK2
|
; RUN: llvm-dis < %t.out.1.3.import.bc | FileCheck %s --check-prefix=CHECK2
|
||||||
; RUN: llvm-nm %t.out.1 | FileCheck %s --check-prefix=CHECK2-NM
|
; RUN: llvm-nm %t.out.1 | FileCheck %s --check-prefix=CHECK2-NM
|
||||||
|
|
||||||
|
; RUN: llvm-bcanalyzer -dump %t.out.index.bc | FileCheck %s --check-prefix=COMBINED
|
||||||
|
; Live, NotEligibleForImport, Internal
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=55
|
||||||
|
; Live, Internal
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=39
|
||||||
|
; Live, External
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=32
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=32
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=32
|
||||||
|
; (Dead)
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=0
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=0
|
||||||
|
; COMBINED-DAG: <COMBINED {{.*}} op2=0
|
||||||
|
|
||||||
; Dead-stripping on the index allows to internalize these,
|
; Dead-stripping on the index allows to internalize these,
|
||||||
; and limit the import of @baz thanks to early pruning.
|
; and limit the import of @baz thanks to early pruning.
|
||||||
; CHECK-NOT: available_externally {{.*}} @baz()
|
; CHECK-NOT: available_externally {{.*}} @baz()
|
||||||
|
@ -35,7 +49,7 @@
|
||||||
; Make sure we didn't internalize @boo, which is reachable via
|
; Make sure we didn't internalize @boo, which is reachable via
|
||||||
; llvm.global_ctors
|
; llvm.global_ctors
|
||||||
; CHECK2: define void @boo()
|
; CHECK2: define void @boo()
|
||||||
; We should have eventually revoved @baz since it was internalized and unused
|
; We should have eventually removed @baz since it was internalized and unused
|
||||||
; CHECK2-NM-NOT: _baz
|
; CHECK2-NM-NOT: _baz
|
||||||
|
|
||||||
; The final binary should not contain any of the dead functions,
|
; The final binary should not contain any of the dead functions,
|
||||||
|
|
Loading…
Reference in New Issue