mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Skip CFI for dead functions.
Differential Revision: https://reviews.llvm.org/D33805 llvm-svn: 304578
This commit is contained in:
parent
6d07f219bd
commit
100205f083
@ -128,6 +128,8 @@ template <> struct MappingTraits<TypeIdSummary> {
|
||||
};
|
||||
|
||||
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<GlobalValueSummaryMapTy> {
|
||||
}
|
||||
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<GlobalValueSummaryMapTy> {
|
||||
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<ModuleSummaryIndex> {
|
||||
static void mapping(IO &io, ModuleSummaryIndex& index) {
|
||||
io.mapOptional("GlobalValueMap", index.GlobalValueMap);
|
||||
io.mapOptional("TypeIdMap", index.TypeIdMap);
|
||||
io.mapOptional("WithGlobalValueDeadStripping",
|
||||
index.WithGlobalValueDeadStripping);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1,7 +1,8 @@
|
||||
---
|
||||
GlobalValueMap:
|
||||
42:
|
||||
- TypeTests: [123]
|
||||
- Live: true
|
||||
TypeTests: [123]
|
||||
TypeIdMap:
|
||||
typeid1:
|
||||
TTRes:
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
GlobalValueMap:
|
||||
42:
|
||||
- Live: false
|
||||
TypeTests: [14276520915468743435] # guid("typeid1")
|
||||
WithGlobalValueDeadStripping: true
|
||||
...
|
@ -1,5 +1,6 @@
|
||||
---
|
||||
GlobalValueMap:
|
||||
42:
|
||||
- TypeTests: [14276520915468743435, 15427464259790519041] # guid("typeid1"), guid("typeid2")
|
||||
- Live: true
|
||||
TypeTests: [14276520915468743435, 15427464259790519041] # guid("typeid1"), guid("typeid2")
|
||||
...
|
||||
|
14
test/Transforms/LowerTypeTests/export-dead.ll
Normal file
14
test/Transforms/LowerTypeTests/export-dead.ll
Normal file
@ -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
|
||||
|
||||
@foo = constant i32 42, !type !0
|
||||
|
||||
!0 = !{i32 0, !"typeid1"}
|
||||
|
||||
; CHECK-NOT: @__typeid_typeid1_global_addr =
|
||||
|
||||
; SUMMARY: TypeIdMap:
|
||||
; SUMMARY-NEXT: WithGlobalValueDeadStripping: true
|
||||
; SUMMARY-NEXT: ...
|
@ -4,4 +4,5 @@
|
||||
; CHECK: ---
|
||||
; CHECK-NEXT: GlobalValueMap:
|
||||
; CHECK-NEXT: TypeIdMap:
|
||||
; CHECK-NEXT: WithGlobalValueDeadStripping: false
|
||||
; CHECK-NEXT: ...
|
||||
|
@ -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:
|
||||
|
@ -1,7 +1,8 @@
|
||||
---
|
||||
GlobalValueMap:
|
||||
42:
|
||||
- TypeTestAssumeVCalls:
|
||||
- Live: true
|
||||
TypeTestAssumeVCalls:
|
||||
- GUID: 14276520915468743435 # typeid1
|
||||
Offset: 0
|
||||
TypeCheckedLoadVCalls:
|
||||
|
@ -1,7 +1,8 @@
|
||||
---
|
||||
GlobalValueMap:
|
||||
42:
|
||||
- TypeTestAssumeVCalls:
|
||||
- Live: true
|
||||
TypeTestAssumeVCalls:
|
||||
- GUID: 123
|
||||
Offset: 0
|
||||
- GUID: 456
|
||||
|
@ -4,4 +4,5 @@
|
||||
; CHECK: ---
|
||||
; CHECK-NEXT: GlobalValueMap:
|
||||
; CHECK-NEXT: TypeIdMap:
|
||||
; CHECK-NEXT: WithGlobalValueDeadStripping: false
|
||||
; CHECK-NEXT: ...
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user