• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -passes='print<func-properties>' -disable-output 2>&1 | FileCheck %s
2
3define i32 @main() {
4; CHECK-DAG: Printing analysis results of CFA for function 'main':
5
6entry:
7  %retval = alloca i32, align 4
8  %mat1 = alloca [2 x [2 x i32]], align 16
9  %mat2 = alloca [2 x [2 x i32]], align 16
10  %res = alloca [2 x [2 x i32]], align 16
11  %i = alloca i32, align 4
12  %j = alloca i32, align 4
13  store i32 0, i32* %retval, align 4
14  %arraydecay = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %mat1, i64 0, i64 0
15  %arraydecay1 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %mat2, i64 0, i64 0
16  %arraydecay2 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %res, i64 0, i64 0
17  call void @multiply([2 x i32]* %arraydecay, [2 x i32]* %arraydecay1, [2 x i32]* %arraydecay2)
18  ret i32 0
19}
20; CHECK-DAG: BasicBlockCount: 1
21; CHECK-DAG: BlocksReachedFromConditionalInstruction: 0
22; CHECK-DAG: Uses: 1
23; CHECK-DAG: DirectCallsToDefinedFunctions: 1
24; CHECK-DAG: LoadInstCount: 0
25; CHECK-DAG: StoreInstCount: 1
26; CHECK-DAG: MaxLoopDepth: 0
27; CHECK-DAG: TopLevelLoopCount: 0
28
29define void @multiply([2 x i32]* %mat1, [2 x i32]* %mat2, [2 x i32]* %res) {
30; CHECK-DAG: Printing analysis results of CFA for function 'multiply':
31entry:
32  %mat1.addr = alloca [2 x i32]*, align 8
33  %mat2.addr = alloca [2 x i32]*, align 8
34  %res.addr = alloca [2 x i32]*, align 8
35  %i = alloca i32, align 4
36  %j = alloca i32, align 4
37  %k = alloca i32, align 4
38  store [2 x i32]* %mat1, [2 x i32]** %mat1.addr, align 8
39  store [2 x i32]* %mat2, [2 x i32]** %mat2.addr, align 8
40  store [2 x i32]* %res, [2 x i32]** %res.addr, align 8
41  store i32 0, i32* %i, align 4
42  br label %for.cond
43
44for.cond:                                         ; preds = %for.inc24, %entry
45  %0 = load i32, i32* %i, align 4
46  %cmp = icmp slt i32 %0, 2
47  br i1 %cmp, label %for.body, label %for.end26
48
49for.body:                                         ; preds = %for.cond
50  store i32 0, i32* %j, align 4
51  br label %for.cond1
52
53for.cond1:                                        ; preds = %for.inc21, %for.body
54  %1 = load i32, i32* %j, align 4
55  %cmp2 = icmp slt i32 %1, 2
56  br i1 %cmp2, label %for.body3, label %for.end23
57
58for.body3:                                        ; preds = %for.cond1
59  %2 = load [2 x i32]*, [2 x i32]** %res.addr, align 8
60  %3 = load i32, i32* %i, align 4
61  %idxprom = sext i32 %3 to i64
62  %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 %idxprom
63  %4 = load i32, i32* %j, align 4
64  %idxprom4 = sext i32 %4 to i64
65  %arrayidx5 = getelementptr inbounds [2 x i32], [2 x i32]* %arrayidx, i64 0, i64 %idxprom4
66  store i32 0, i32* %arrayidx5, align 4
67  store i32 0, i32* %k, align 4
68  br label %for.cond6
69
70for.cond6:                                        ; preds = %for.inc, %for.body3
71  %5 = load i32, i32* %k, align 4
72  %cmp7 = icmp slt i32 %5, 2
73  br i1 %cmp7, label %for.body8, label %for.end
74
75for.body8:                                        ; preds = %for.cond6
76  %6 = load [2 x i32]*, [2 x i32]** %mat1.addr, align 8
77  %7 = load i32, i32* %i, align 4
78  %idxprom9 = sext i32 %7 to i64
79  %arrayidx10 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 %idxprom9
80  %8 = load i32, i32* %k, align 4
81  %idxprom11 = sext i32 %8 to i64
82  %arrayidx12 = getelementptr inbounds [2 x i32], [2 x i32]* %arrayidx10, i64 0, i64 %idxprom11
83  %9 = load i32, i32* %arrayidx12, align 4
84  %10 = load [2 x i32]*, [2 x i32]** %mat2.addr, align 8
85  %11 = load i32, i32* %k, align 4
86  %idxprom13 = sext i32 %11 to i64
87  %arrayidx14 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 %idxprom13
88  %12 = load i32, i32* %j, align 4
89  %idxprom15 = sext i32 %12 to i64
90  %arrayidx16 = getelementptr inbounds [2 x i32], [2 x i32]* %arrayidx14, i64 0, i64 %idxprom15
91  %13 = load i32, i32* %arrayidx16, align 4
92  %mul = mul nsw i32 %9, %13
93  %14 = load [2 x i32]*, [2 x i32]** %res.addr, align 8
94  %15 = load i32, i32* %i, align 4
95  %idxprom17 = sext i32 %15 to i64
96  %arrayidx18 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 %idxprom17
97  %16 = load i32, i32* %j, align 4
98  %idxprom19 = sext i32 %16 to i64
99  %arrayidx20 = getelementptr inbounds [2 x i32], [2 x i32]* %arrayidx18, i64 0, i64 %idxprom19
100  %17 = load i32, i32* %arrayidx20, align 4
101  %add = add nsw i32 %17, %mul
102  store i32 %add, i32* %arrayidx20, align 4
103  br label %for.inc
104
105for.inc:                                          ; preds = %for.body8
106  %18 = load i32, i32* %k, align 4
107  %inc = add nsw i32 %18, 1
108  store i32 %inc, i32* %k, align 4
109  br label %for.cond6
110
111for.end:                                          ; preds = %for.cond6
112  br label %for.inc21
113
114for.inc21:                                        ; preds = %for.end
115  %19 = load i32, i32* %j, align 4
116  %inc22 = add nsw i32 %19, 1
117  store i32 %inc22, i32* %j, align 4
118  br label %for.cond1
119
120for.end23:                                        ; preds = %for.cond1
121  br label %for.inc24
122
123for.inc24:                                        ; preds = %for.end23
124  %20 = load i32, i32* %i, align 4
125  %inc25 = add nsw i32 %20, 1
126  store i32 %inc25, i32* %i, align 4
127  br label %for.cond
128
129for.end26:                                        ; preds = %for.cond
130  ret void
131}
132
133; CHECK-DAG: BasicBlockCount: 13
134; CHECK-DAG: BlocksReachedFromConditionalInstruction: 6
135; CHECK-DAG: Uses: 2
136; CHECK-DAG: DirectCallsToDefinedFunctions: 0
137; CHECK-DAG: LoadInstCount: 21
138; CHECK-DAG: StoreInstCount: 11
139; CHECK-DAG: MaxLoopDepth: 3
140; CHECK-DAG: TopLevelLoopCount: 1