llvm.org GIT mirror llvm / f5c8258
[ThinLTO] Fix dead stripping analysis for SamplePGO Summary: The fix for dead stripping analysis in the case of SamplePGO indirect calls to local functions (r313151) introduced the possibility of an infinite loop. Make sure we check for the value being already live after we update it for SamplePGO indirect call handling. Reviewers: danielcdh Subscribers: mehdi_amini, inglorion, llvm-commits, eraman Differential Revision: https://reviews.llvm.org/D38086 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313766 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 2 years ago
3 changed file(s) with 98 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
462462 // Make value live and add it to the worklist if it was not live before.
463463 // FIXME: we should only make the prevailing copy live here
464464 auto visit = [&](ValueInfo VI) {
465 for (auto &S : VI.getSummaryList())
466 if (S->isLive())
467 return;
468465 // FIXME: If we knew which edges were created for indirect call profiles,
469466 // we could skip them here. Any that are live should be reached via
470467 // other edges, e.g. reference edges. Otherwise, using a profile collected
476473 VI = updateValueInfoForIndirectCalls(Index, VI);
477474 if (!VI)
478475 return;
476 for (auto &S : VI.getSummaryList())
477 if (S->isLive())
478 return;
479479 for (auto &S : VI.getSummaryList())
480480 S->setLive(true);
481481 ++LiveSymbols;
0 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1 target triple = "x86_64-unknown-linux-gnu"
2
3 @fptr = external local_unnamed_addr global void ()*, align 8
4
5 ; Function Attrs: norecurse nounwind uwtable
6 define void @_Z6updatei(i32 %i) local_unnamed_addr #0 {
7 entry:
8 store void ()* @_ZL3foov, void ()** @fptr, align 8
9 ret void
10 }
11
12 ; Function Attrs: nounwind readnone uwtable
13 define internal void @_ZL3foov() !prof !34 {
14 entry:
15 %0 = load void ()*, void ()** @fptr, align 8
16 tail call void %0(), !prof !40
17 ret void
18 }
19
20 !llvm.dbg.cu = !{!0}
21 !llvm.module.flags = !{!3}
22 !llvm.ident = !{!31}
23
24 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 297016)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
25 !1 = !DIFile(filename: "b.cc", directory: "/ssd/llvm/abc/small")
26 !2 = !{}
27 !3 = !{i32 2, !"Debug Info Version", i32 3}
28 !31 = !{!"clang version 5.0.0 (trunk 297016)"}
29 !34 = !{!"function_entry_count", i64 1}
30 !40 = !{!"VP", i32 0, i64 3000, i64 -8789629626369651636, i64 3000}
0 ; REQUIRES: x86-registered-target
1
2 ; Do setup work for all below tests: generate bitcode and combined index
3 ; RUN: opt -module-summary %s -o %t.bc
4 ; RUN: opt -module-summary %p/Inputs/thinlto_samplepgo_icp3.ll -o %t2.bc
5
6 ; Test to make sure importing and dead stripping works in the
7 ; case where the target is a local function that also indirectly calls itself.
8 ; RUN: llvm-lto2 run -save-temps -o %t3 %t.bc %t2.bc -r %t.bc,fptr,plx -r %t.bc,main,plx -r %t2.bc,_Z6updatei,pl -r %t2.bc,fptr,l -print-imports 2>&1 | FileCheck %s --check-prefix=IMPORTS
9 ; Make sure we import the promted indirectly called target
10 ; IMPORTS: Import _ZL3foov.llvm.0
11
12 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
13 target triple = "x86_64-unknown-linux-gnu"
14
15 @fptr = local_unnamed_addr global void ()* null, align 8
16
17 ; Function Attrs: norecurse uwtable
18 define i32 @main() local_unnamed_addr #0 !prof !34 {
19 entry:
20 %0 = load void ()*, void ()** @fptr, align 8
21 ; ICALL-PROM: br i1 %{{[0-9]+}}, label %if.true.direct_targ, label %if.false.orig_indirect
22 tail call void %0(), !prof !40
23 ret i32 0
24 }
25
26 !llvm.dbg.cu = !{!0}
27 !llvm.module.flags = !{!3,!4}
28 !llvm.ident = !{!31}
29
30 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 297016)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
31 !1 = !DIFile(filename: "main.cc", directory: ".")
32 !2 = !{}
33 !3 = !{i32 2, !"Debug Info Version", i32 3}
34 !4 = !{i32 1, !"ProfileSummary", !5}
35 !5 = !{!6, !7, !8, !9, !10, !11, !12, !13}
36 !6 = !{!"ProfileFormat", !"SampleProfile"}
37 !7 = !{!"TotalCount", i64 3003}
38 !8 = !{!"MaxCount", i64 3000}
39 !9 = !{!"MaxInternalCount", i64 0}
40 !10 = !{!"MaxFunctionCount", i64 0}
41 !11 = !{!"NumCounts", i64 3}
42 !12 = !{!"NumFunctions", i64 1}
43 !13 = !{!"DetailedSummary", !14}
44 !14 = !{!15, !16, !17, !18, !19, !20, !20, !21, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30}
45 !15 = !{i32 10000, i64 3000, i32 1}
46 !16 = !{i32 100000, i64 3000, i32 1}
47 !17 = !{i32 200000, i64 3000, i32 1}
48 !18 = !{i32 300000, i64 3000, i32 1}
49 !19 = !{i32 400000, i64 3000, i32 1}
50 !20 = !{i32 500000, i64 3000, i32 1}
51 !21 = !{i32 600000, i64 3000, i32 1}
52 !22 = !{i32 700000, i64 3000, i32 1}
53 !23 = !{i32 800000, i64 3000, i32 1}
54 !24 = !{i32 900000, i64 3000, i32 1}
55 !25 = !{i32 950000, i64 3000, i32 1}
56 !26 = !{i32 990000, i64 3000, i32 1}
57 !27 = !{i32 999000, i64 3000, i32 1}
58 !28 = !{i32 999900, i64 2, i32 2}
59 !29 = !{i32 999990, i64 2, i32 2}
60 !30 = !{i32 999999, i64 2, i32 2}
61 !31 = !{!"clang version 5.0.0 (trunk 297016)"}
62 !34 = !{!"function_entry_count", i64 1}
63 !40 = !{!"VP", i32 0, i64 3000, i64 -8789629626369651636, i64 3000}