[llvm] r304578 - Skip CFI for dead functions.
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 2 11:24:24 PDT 2017
Author: eugenis
Date: Fri Jun 2 13:24:23 2017
New Revision: 304578
URL: http://llvm.org/viewvc/llvm-project?rev=304578&view=rev
Log:
Skip CFI for dead functions.
Differential Revision: https://reviews.llvm.org/D33805
Added:
llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-dead.yaml
llvm/trunk/test/Transforms/LowerTypeTests/export-dead.ll
Modified:
llvm/trunk/include/llvm/IR/ModuleSummaryIndexYAML.h
llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-unsat.yaml
llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml
llvm/trunk/test/Transforms/LowerTypeTests/export-nothing.ll
llvm/trunk/test/Transforms/LowerTypeTests/import-unsat.ll
llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/export.yaml
llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/import-indir.yaml
llvm/trunk/test/Transforms/WholeProgramDevirt/export-nothing.ll
llvm/trunk/test/Transforms/WholeProgramDevirt/export-single-impl.ll
llvm/trunk/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
llvm/trunk/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
llvm/trunk/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll
llvm/trunk/test/Transforms/WholeProgramDevirt/import-indir.ll
Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndexYAML.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndexYAML.h?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndexYAML.h (original)
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndexYAML.h Fri Jun 2 13:24:23 2017
@@ -128,6 +128,8 @@ template <> struct MappingTraits<TypeIdS
};
struct FunctionSummaryYaml {
+ unsigned Linkage;
+ bool NotEligibleToImport, Live;
std::vector<uint64_t> TypeTests;
std::vector<FunctionSummary::VFuncId> TypeTestAssumeVCalls,
TypeCheckedLoadVCalls;
@@ -168,6 +170,9 @@ namespace yaml {
template <> struct MappingTraits<FunctionSummaryYaml> {
static void mapping(IO &io, FunctionSummaryYaml& summary) {
+ io.mapOptional("Linkage", summary.Linkage);
+ io.mapOptional("NotEligibleToImport", summary.NotEligibleToImport);
+ io.mapOptional("Live", summary.Live);
io.mapOptional("TypeTests", summary.TypeTests);
io.mapOptional("TypeTestAssumeVCalls", summary.TypeTestAssumeVCalls);
io.mapOptional("TypeCheckedLoadVCalls", summary.TypeCheckedLoadVCalls);
@@ -199,12 +204,12 @@ template <> struct CustomMappingTraits<G
}
auto &Elem = V[KeyInt];
for (auto &FSum : FSums) {
- GlobalValueSummary::GVFlags GVFlags(GlobalValue::ExternalLinkage, false,
- false);
Elem.SummaryList.push_back(llvm::make_unique<FunctionSummary>(
- GVFlags, 0, ArrayRef<ValueInfo>{},
- ArrayRef<FunctionSummary::EdgeTy>{}, std::move(FSum.TypeTests),
- std::move(FSum.TypeTestAssumeVCalls),
+ GlobalValueSummary::GVFlags(
+ static_cast<GlobalValue::LinkageTypes>(FSum.Linkage),
+ FSum.NotEligibleToImport, FSum.Live),
+ 0, ArrayRef<ValueInfo>{}, ArrayRef<FunctionSummary::EdgeTy>{},
+ std::move(FSum.TypeTests), std::move(FSum.TypeTestAssumeVCalls),
std::move(FSum.TypeCheckedLoadVCalls),
std::move(FSum.TypeTestAssumeConstVCalls),
std::move(FSum.TypeCheckedLoadConstVCalls)));
@@ -216,8 +221,10 @@ template <> struct CustomMappingTraits<G
for (auto &Sum : P.second.SummaryList) {
if (auto *FSum = dyn_cast<FunctionSummary>(Sum.get()))
FSums.push_back(FunctionSummaryYaml{
- FSum->type_tests(), FSum->type_test_assume_vcalls(),
- FSum->type_checked_load_vcalls(),
+ FSum->flags().Linkage,
+ static_cast<bool>(FSum->flags().NotEligibleToImport),
+ static_cast<bool>(FSum->flags().Live), FSum->type_tests(),
+ FSum->type_test_assume_vcalls(), FSum->type_checked_load_vcalls(),
FSum->type_test_assume_const_vcalls(),
FSum->type_checked_load_const_vcalls()});
}
@@ -231,6 +238,8 @@ template <> struct MappingTraits<ModuleS
static void mapping(IO &io, ModuleSummaryIndex& index) {
io.mapOptional("GlobalValueMap", index.GlobalValueMap);
io.mapOptional("TypeIdMap", index.TypeIdMap);
+ io.mapOptional("WithGlobalValueDeadStripping",
+ index.WithGlobalValueDeadStripping);
}
};
Modified: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp Fri Jun 2 13:24:23 2017
@@ -1442,9 +1442,8 @@ bool LowerTypeTestsModule::lower() {
for (auto &P : *ExportSummary) {
for (auto &S : P.second.SummaryList) {
auto *FS = dyn_cast<FunctionSummary>(S.get());
- if (!FS)
+ if (!FS || !ExportSummary->isGlobalValueLive(FS))
continue;
- // FIXME: Only add live functions.
for (GlobalValue::GUID G : FS->type_tests())
for (Metadata *MD : MetadataByGUID[G])
AddTypeIdUse(MD).IsExported = true;
Modified: llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-unsat.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-unsat.yaml?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-unsat.yaml (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-unsat.yaml Fri Jun 2 13:24:23 2017
@@ -1,7 +1,8 @@
---
GlobalValueMap:
42:
- - TypeTests: [123]
+ - Live: true
+ TypeTests: [123]
TypeIdMap:
typeid1:
TTRes:
Added: llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-dead.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-dead.yaml?rev=304578&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-dead.yaml (added)
+++ llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-dead.yaml Fri Jun 2 13:24:23 2017
@@ -0,0 +1,7 @@
+---
+GlobalValueMap:
+ 42:
+ - Live: false
+ TypeTests: [14276520915468743435] # guid("typeid1")
+WithGlobalValueDeadStripping: true
+...
Modified: llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/Inputs/use-typeid1-typeid2.yaml Fri Jun 2 13:24:23 2017
@@ -1,5 +1,6 @@
---
GlobalValueMap:
42:
- - TypeTests: [14276520915468743435, 15427464259790519041] # guid("typeid1"), guid("typeid2")
+ - Live: true
+ TypeTests: [14276520915468743435, 15427464259790519041] # guid("typeid1"), guid("typeid2")
...
Added: llvm/trunk/test/Transforms/LowerTypeTests/export-dead.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/export-dead.ll?rev=304578&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/export-dead.ll (added)
+++ llvm/trunk/test/Transforms/LowerTypeTests/export-dead.ll Fri Jun 2 13:24:23 2017
@@ -0,0 +1,14 @@
+; The only use of "typeid1" is in a dead function. Export nothing.
+
+; RUN: opt -S -lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-dead.yaml -lowertypetests-write-summary=%t < %s | FileCheck %s
+; RUN: FileCheck --check-prefix=SUMMARY %s < %t
+
+ at foo = constant i32 42, !type !0
+
+!0 = !{i32 0, !"typeid1"}
+
+; CHECK-NOT: @__typeid_typeid1_global_addr =
+
+; SUMMARY: TypeIdMap:
+; SUMMARY-NEXT: WithGlobalValueDeadStripping: true
+; SUMMARY-NEXT: ...
Modified: llvm/trunk/test/Transforms/LowerTypeTests/export-nothing.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/export-nothing.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/export-nothing.ll (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/export-nothing.ll Fri Jun 2 13:24:23 2017
@@ -4,4 +4,5 @@
; CHECK: ---
; CHECK-NEXT: GlobalValueMap:
; CHECK-NEXT: TypeIdMap:
+; CHECK-NEXT: WithGlobalValueDeadStripping: false
; CHECK-NEXT: ...
Modified: llvm/trunk/test/Transforms/LowerTypeTests/import-unsat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/import-unsat.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/import-unsat.ll (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/import-unsat.ll Fri Jun 2 13:24:23 2017
@@ -4,7 +4,10 @@
; SUMMARY: GlobalValueMap:
; SUMMARY-NEXT: 42:
-; SUMMARY-NEXT: - TypeTests: [ 123 ]
+; SUMMARY-NEXT: - Linkage: 0
+; SUMMARY-NEXT: NotEligibleToImport: false
+; SUMMARY-NEXT: Live: true
+; SUMMARY-NEXT: TypeTests: [ 123 ]
; SUMMARY-NEXT: TypeIdMap:
; SUMMARY-NEXT: typeid1:
; SUMMARY-NEXT: TTRes:
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/export.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/export.yaml?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/export.yaml (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/export.yaml Fri Jun 2 13:24:23 2017
@@ -1,7 +1,8 @@
---
GlobalValueMap:
42:
- - TypeTestAssumeVCalls:
+ - Live: true
+ TypeTestAssumeVCalls:
- GUID: 14276520915468743435 # typeid1
Offset: 0
TypeCheckedLoadVCalls:
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/import-indir.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/import-indir.yaml?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/import-indir.yaml (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/Inputs/import-indir.yaml Fri Jun 2 13:24:23 2017
@@ -1,7 +1,8 @@
---
GlobalValueMap:
42:
- - TypeTestAssumeVCalls:
+ - Live: true
+ TypeTestAssumeVCalls:
- GUID: 123
Offset: 0
- GUID: 456
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/export-nothing.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/export-nothing.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/export-nothing.ll (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/export-nothing.ll Fri Jun 2 13:24:23 2017
@@ -4,4 +4,5 @@
; CHECK: ---
; CHECK-NEXT: GlobalValueMap:
; CHECK-NEXT: TypeIdMap:
+; CHECK-NEXT: WithGlobalValueDeadStripping: false
; CHECK-NEXT: ...
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/export-single-impl.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/export-single-impl.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/export-single-impl.ll (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/export-single-impl.ll Fri Jun 2 13:24:23 2017
@@ -38,6 +38,7 @@
; SUMMARY-NEXT: Kind: SingleImpl
; SUMMARY-NEXT: SingleImplName: 'vf4$merged'
; SUMMARY-NEXT: ResByArg:
+; SUMMARY-NEXT: WithGlobalValueDeadStripping: false
; SUMMARY-NEXT: ...
; CHECK: @vt1 = constant void (i8*)* @vf1
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll Fri Jun 2 13:24:23 2017
@@ -1,8 +1,7 @@
; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -S -o - %s | FileCheck %s
; RUN: FileCheck --check-prefix=SUMMARY %s < %t
-; SUMMARY: - TypeTests:
-; SUMMARY-NEXT: TypeTestAssumeVCalls:
+; SUMMARY-NOT: TypeTests:
; SUMMARY: TypeIdMap:
; SUMMARY-NEXT: typeid4:
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll Fri Jun 2 13:24:23 2017
@@ -1,8 +1,7 @@
; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -S -o - %s | FileCheck %s
; RUN: FileCheck --check-prefix=SUMMARY %s < %t
-; SUMMARY: - TypeTests:
-; SUMMARY-NEXT: TypeTestAssumeVCalls:
+; SUMMARY-NOT: TypeTests:
; SUMMARY: TypeIdMap:
; SUMMARY-NEXT: typeid3:
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/export-unsuccessful-checked.ll Fri Jun 2 13:24:23 2017
@@ -1,7 +1,7 @@
; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -o /dev/null %s
; RUN: FileCheck %s < %t
-; CHECK: - TypeTests: [ 15427464259790519041, 17525413373118030901 ]
+; CHECK: TypeTests: [ 15427464259790519041, 17525413373118030901 ]
; CHECK-NEXT: TypeTestAssumeVCalls:
@vt1a = constant void (i8*)* @vf1a, !type !0
Modified: llvm/trunk/test/Transforms/WholeProgramDevirt/import-indir.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/WholeProgramDevirt/import-indir.ll?rev=304578&r1=304577&r2=304578&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/WholeProgramDevirt/import-indir.ll (original)
+++ llvm/trunk/test/Transforms/WholeProgramDevirt/import-indir.ll Fri Jun 2 13:24:23 2017
@@ -4,7 +4,9 @@
; SUMMARY: GlobalValueMap:
; SUMMARY-NEXT: 42:
-; SUMMARY-NEXT: - TypeTests:
+; SUMMARY-NEXT: - Linkage: 0
+; SUMMARY-NEXT: NotEligibleToImport: false
+; SUMMARY-NEXT: Live: true
; SUMMARY-NEXT: TypeTestAssumeVCalls:
; SUMMARY-NEXT: - GUID: 123
; SUMMARY-NEXT: Offset: 0
More information about the llvm-commits
mailing list