1cee313d2SEric Christopher; REQUIRES: x86-registered-target
2cee313d2SEric Christopher
3cee313d2SEric Christopher; RUN: opt -module-summary %s -o %t.bc
4cee313d2SEric Christopher
5cee313d2SEric Christopher; Tests that with dead stripping in the thin link enabled (default), we do not
6cee313d2SEric Christopher; promote to target of the dropped dead symbol _ZL3foov. This can happen with a
7cee313d2SEric Christopher; sample profile collected for one binary used to  optimize for another binary.
8cee313d2SEric Christopher; RUN: llvm-lto2 run -save-temps -o %t2 %t.bc -r %t.bc,fptr,plx \
9cee313d2SEric Christopher; RUN:		-r %t.bc,main,plx -r %t.bc,_ZL3foov,l
10cee313d2SEric Christopher; RUN: llvm-dis < %t2.1.4.opt.bc | FileCheck %s --check-prefix=OPT
11cee313d2SEric Christopher; RUN: llvm-lto2 run -save-temps -o %t2 %t.bc -r %t.bc,fptr,plx \
12cee313d2SEric Christopher; RUN: 		-r %t.bc,main,plx -r %t.bc,_ZL3foov,l -compute-dead=false
13cee313d2SEric Christopher; RUN: llvm-dis < %t2.1.4.opt.bc | FileCheck %s --check-prefix=OPT-NODEAD
14cee313d2SEric Christopher
157b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
16cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
17cee313d2SEric Christopher
18*9ff36df5SFangrui Song@fptr = local_unnamed_addr global ptr null, align 8
19cee313d2SEric Christopher
20cee313d2SEric Christopherdefine void @_ZL3foov() #1 {
21cee313d2SEric Christopherentry:
22cee313d2SEric Christopher  ret void
23cee313d2SEric Christopher}
24cee313d2SEric Christopher
25cee313d2SEric Christopherdefine i32 @main() local_unnamed_addr #0 !prof !34 {
26cee313d2SEric Christopherentry:
27*9ff36df5SFangrui Song  %0 = load ptr, ptr @fptr, align 8
28cee313d2SEric Christopher; OPT-NOT: label %if.false.orig_indirect
29cee313d2SEric Christopher; OPT-NODEAD: br i1 %{{[0-9]+}}, label %if.end.icp, label %if.false.orig_indirect
30cee313d2SEric Christopher  tail call void %0(), !prof !40
31cee313d2SEric Christopher  ret i32 0
32cee313d2SEric Christopher}
33cee313d2SEric Christopher
34cee313d2SEric Christopher!llvm.dbg.cu = !{!0}
35cee313d2SEric Christopher!llvm.module.flags = !{!3,!4}
36cee313d2SEric Christopher!llvm.ident = !{!31}
37cee313d2SEric Christopher
38cee313d2SEric Christopher!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)
39cee313d2SEric Christopher!1 = !DIFile(filename: "main.cc", directory: ".")
40cee313d2SEric Christopher!2 = !{}
41cee313d2SEric Christopher!3 = !{i32 2, !"Debug Info Version", i32 3}
42cee313d2SEric Christopher!4 = !{i32 1, !"ProfileSummary", !5}
43cee313d2SEric Christopher!5 = !{!6, !7, !8, !9, !10, !11, !12, !13}
44cee313d2SEric Christopher!6 = !{!"ProfileFormat", !"SampleProfile"}
45cee313d2SEric Christopher!7 = !{!"TotalCount", i64 3003}
46cee313d2SEric Christopher!8 = !{!"MaxCount", i64 3000}
47cee313d2SEric Christopher!9 = !{!"MaxInternalCount", i64 0}
48cee313d2SEric Christopher!10 = !{!"MaxFunctionCount", i64 0}
49cee313d2SEric Christopher!11 = !{!"NumCounts", i64 3}
50cee313d2SEric Christopher!12 = !{!"NumFunctions", i64 1}
51cee313d2SEric Christopher!13 = !{!"DetailedSummary", !14}
52cee313d2SEric Christopher!14 = !{!15, !16, !17, !18, !19, !20, !20, !21, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30}
53cee313d2SEric Christopher!15 = !{i32 10000, i64 3000, i32 1}
54cee313d2SEric Christopher!16 = !{i32 100000, i64 3000, i32 1}
55cee313d2SEric Christopher!17 = !{i32 200000, i64 3000, i32 1}
56cee313d2SEric Christopher!18 = !{i32 300000, i64 3000, i32 1}
57cee313d2SEric Christopher!19 = !{i32 400000, i64 3000, i32 1}
58cee313d2SEric Christopher!20 = !{i32 500000, i64 3000, i32 1}
59cee313d2SEric Christopher!21 = !{i32 600000, i64 3000, i32 1}
60cee313d2SEric Christopher!22 = !{i32 700000, i64 3000, i32 1}
61cee313d2SEric Christopher!23 = !{i32 800000, i64 3000, i32 1}
62cee313d2SEric Christopher!24 = !{i32 900000, i64 3000, i32 1}
63cee313d2SEric Christopher!25 = !{i32 950000, i64 3000, i32 1}
64cee313d2SEric Christopher!26 = !{i32 990000, i64 3000, i32 1}
65cee313d2SEric Christopher!27 = !{i32 999000, i64 3000, i32 1}
66cee313d2SEric Christopher!28 = !{i32 999900, i64 2, i32 2}
67cee313d2SEric Christopher!29 = !{i32 999990, i64 2, i32 2}
68cee313d2SEric Christopher!30 = !{i32 999999, i64 2, i32 2}
69cee313d2SEric Christopher!31 = !{!"clang version 5.0.0 (trunk 297016)"}
70cee313d2SEric Christopher!34 = !{!"function_entry_count", i64 1}
71cee313d2SEric Christopher!40 = !{!"VP", i32 0, i64 3000, i64 -8789629626369651636, i64 3000}
72