Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Inline] Attempt to delete any discardable if unused functions
Previously we limited ourselves to only internal/private functions. We can also delete linkonce_odr functions. Minor compile time wins: https://llvm-compile-time-tracker.com/compare.php?from=d51e3474e060cb0e90dc2e2487f778b0d3e6a8de&to=bccffe3f8d5dd4dda884c9ac1f93e51772519cad&stat=instructions Major memory wins on tramp3d: https://llvm-compile-time-tracker.com/compare.php?from=d51e3474e060cb0e90dc2e2487f778b0d3e6a8de&to=bccffe3f8d5dd4dda884c9ac1f93e51772519cad&stat=max-rss Relanding with fix for compile times D117236. Reviewed By: nikic, mtrofin Differential Revision: https://reviews.llvm.org/D115545
- Loading branch information
Showing
3 changed files
with
137 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
llvm/test/Transforms/Inline/delete-function-with-metadata-use.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
; RUN: opt -passes=inline < %s -S | FileCheck %s | ||
|
||
; CHECK: define {{.*}}@f1 | ||
; CHECK-NOT: define | ||
|
||
%a = type { i8*, i8* } | ||
|
||
$f3 = comdat any | ||
|
||
define linkonce_odr void @f1() { | ||
call void @f2(void ()* @f3) | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @f2(void ()* %__f) { | ||
call void @llvm.dbg.value(metadata void ()* %__f, metadata !2, metadata !DIExpression()), !dbg !10 | ||
call void %__f() | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @f3() comdat { | ||
ret void | ||
} | ||
|
||
declare void @llvm.dbg.value(metadata, metadata, metadata) | ||
|
||
!llvm.module.flags = !{!0, !1} | ||
|
||
!0 = !{i32 7, !"Dwarf Version", i32 4} | ||
!1 = !{i32 2, !"Debug Info Version", i32 3} | ||
!2 = !DILocalVariable(name: "__f", arg: 3, scope: !3, file: !4, line: 3814, type: !9) | ||
!3 = distinct !DISubprogram(scope: !5, file: !4, line: 3814, type: !6, scopeLine: 3815, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !7, retainedNodes: !7) | ||
!4 = !DIFile(filename: "a", directory: "") | ||
!5 = !DINamespace(name: "std", scope: null) | ||
!6 = !DISubroutineType(types: !7) | ||
!7 = !{} | ||
!8 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !4, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !7, retainedTypes: !7, globals: !7, imports: !7, splitDebugInlining: false, nameTableKind: None) | ||
!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64) | ||
!10 = !DILocation(line: 0, scope: !3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
; RUN: opt -passes=inline < %s -S | FileCheck %s | ||
|
||
; CHECK: define {{.*}}@caller | ||
; CHECK: define {{.*}}@f1 | ||
; CHECK-NOT: define {{.*}}@f2 | ||
; CHECK-NOT: define {{.*}}@f3 | ||
; CHECK-NOT: define {{.*}}@f4 | ||
; CHECK-NOT: define {{.*}}@f5 | ||
; CHECK: define {{.*}}@f6 | ||
; CHECK-NOT: define {{.*}}@f7 | ||
; CHECK-NOT: define {{.*}}@f8 | ||
|
||
$c1 = comdat any | ||
$c2 = comdat any | ||
$c3 = comdat any | ||
|
||
define void @caller() { | ||
call void @f1() | ||
call void @f2() | ||
call void @f3() | ||
call void @f4() | ||
call void @f5() | ||
call void @f6() | ||
call void @f7() | ||
call void @f8() | ||
ret void | ||
} | ||
|
||
define void @f1() { | ||
ret void | ||
} | ||
|
||
define internal void @f2() { | ||
ret void | ||
} | ||
|
||
define private void @f3() { | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @f4() { | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @f5() comdat($c1) { | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @f6() comdat($c2) { | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @g() comdat($c2) { | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @f7() comdat($c3) { | ||
ret void | ||
} | ||
|
||
define linkonce_odr void @f8() comdat($c3) { | ||
ret void | ||
} |