1; RUN: opt -module-summary %s -o %t1.bc
2; RUN: opt -module-summary %p/Inputs/dot-dumper.ll -o %t2.bc
3; RUN: llvm-lto2 run -save-temps %t1.bc %t2.bc -o %t3 \
4; RUN:  -r=%t1.bc,main,px \
5; RUN:  -r=%t1.bc,main_alias,p \
6; RUN:  -r=%t1.bc,foo, \
7; RUN:  -r=%t1.bc,A, \
8; RUN:  -r=%t2.bc,foo,p \
9; RUN:  -r=%t2.bc,bar,p \
10; RUN:  -r=%t2.bc,A,p \
11; RUN:  -r=%t2.bc,B,p
12
13; Never assume specific order of clusters, nodes or edges
14; RUN: cat %t3.index.dot | FileCheck --check-prefix=STRUCTURE %s
15; RUN: cat %t3.index.dot | FileCheck --check-prefix=CLUSTER0 %s
16; RUN: cat %t3.index.dot | FileCheck --check-prefix=CLUSTER1 %s
17
18; STRUCTURE:        digraph Summary {
19; STRUCTURE-DAG:      subgraph cluster_0
20; STRUCTURE-DAG:      subgraph cluster_1
21; STRUCTURE:          // Cross-module edges:
22; STRUCTURE-DAG:      M0_{{[0-9]+}} -> M1_{{[0-9]+}} // call
23; STRUCTURE-DAG:      M0_{{[0-9]+}} -> M1_{{[0-9]+}} [{{.*}}]; // ref
24; STRUCTURE-NEXT:   }
25
26; CLUSTER0:         // Module: {{.*}}1.bc
27; CLUSTER0-NEXT:    subgraph cluster_0 {
28; CLUSTER0-DAG:       M0_[[MAIN_ALIAS:[0-9]+]] [{{.*}}main_alias{{.*}}]; // alias, dead
29; CLUSTER0-DAG:       M0_[[MAIN:[0-9]+]] [{{.*}}main|extern{{.*}}]; // function
30; CLUSTER0-NEXT:      // Edges:
31; CLUSTER0-NEXT:      M0_[[MAIN_ALIAS]] -> M0_[[MAIN]] [{{.*}}]; // alias
32; CLUSTER0-NEXT:    }
33
34; CLUSTER1:         // Module: {{.*}}2.bc
35; CLUSTER1-NEXT:    subgraph cluster_1 {
36; CLUSTER1-DAG:       M1_[[A:[0-9]+]] [{{.*}}A|extern{{.*}}]; // variable
37; CLUSTER1-DAG:       M1_[[FOO:[0-9]+]] [{{.*}}foo|extern{{.*}}]; // function, not eligible to import
38; CLUSTER1-DAG:       M1_[[B:[0-9]+]] [{{.*}}B|extern{{.*}}]; // variable
39; CLUSTER1-DAG:       M1_[[BAR:[0-9]+]] [{{.*}}bar|extern{{.*}}]; // function, dead
40; CLUSTER1-NEXT:      // Edges:
41; CLUSTER1-DAG:       M1_[[FOO]] -> M1_[[B]] [{{.*}}]; // ref
42; CLUSTER1-DAG:       M1_[[FOO]] -> M1_[[A]] [{{.*}}]; // ref
43; CLUSTER1-DAG:     }
44
45target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
46target triple = "x86_64-unknown-linux-gnu"
47
48@A = external local_unnamed_addr global i32, align 4
49
50; Function Attrs: nounwind uwtable
51define i32 @main() local_unnamed_addr {
52  %1 = tail call i32 (...) @foo()
53  %2 = load i32, i32* @A, align 4
54  %3 = add nsw i32 %2, %1
55  ret i32 %3
56}
57@main_alias = weak_odr alias i32 (), i32 ()* @main
58declare i32 @foo(...) local_unnamed_addr
59