Skip to content

Commit ac6eb21

Browse files
authored
Merge pull request diffblue#1858 from danpoe/dependence-graph-fix
Control dependency computation fix
2 parents 10b8b09 + 7002909 commit ac6eb21

File tree

17 files changed

+536
-71
lines changed

17 files changed

+536
-71
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
int a;
2+
3+
void main(void)
4+
{
5+
int i = 0;
6+
7+
if(i < 10)
8+
{
9+
a = 1;
10+
}
11+
else
12+
{
13+
a = 2;
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
CORE
2+
main.c
3+
--dependence-graph --show
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
// First assignment has a control dependency on the if
8+
\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1
9+
// Second assignment has a control dependency on the if
10+
\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 2
11+
--
12+
^warning: ignoring
13+
--
14+
The first regex above matches output portions like shown below (with <N> being a
15+
location number). The intention is to check whether the assignment has a control
16+
dependency on the goto statement.
17+
18+
// <N> file main.c line 7 function main
19+
IF !(i < 10) THEN GOTO 1
20+
21+
**** 3 file main.c line 9 function main
22+
Control dependencies: <N>
23+
24+
// 3 file main.c line 9 function main
25+
a = 1;
26+
27+
The second regex above matches output portions like shown below (with <N> being
28+
a location number). The intention is to check whether the assignment has a
29+
control dependency on the goto statement.
30+
31+
// <N> file main.c line 7 function main
32+
IF !(i < 10) THEN GOTO 1
33+
...
34+
**** 5 file main.c line 13 function main
35+
Control dependencies: <N>
36+
37+
// 5 file main.c line 13 function main
38+
1: a = 2;
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
int a;
2+
3+
void func()
4+
{
5+
}
6+
7+
void main(void)
8+
{
9+
func();
10+
11+
if(a < 10)
12+
{
13+
a = 1;
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CORE
2+
main.c
3+
--dependence-graph --show
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
// Assignment has a control dependency on the if
8+
\/\/ ([0-9]+).*\n.*IF.*a < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1
9+
--
10+
^warning: ignoring
11+
--
12+
The regex above match output portions like shown below (with <N> being a
13+
location number). The intention is to check whether the assignment has a control
14+
dependency on the goto statement.
15+
16+
// <N> file main.c line 7 function main
17+
IF !(i < 10) THEN GOTO 1
18+
...
19+
**** 3 file main.c line 9 function main
20+
Control dependencies: <N>
21+
22+
// 3 file main.c line 9 function main
23+
a = 1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
int a;
2+
3+
void func()
4+
{
5+
}
6+
7+
void main(void)
8+
{
9+
if(a < 7)
10+
{
11+
goto L;
12+
}
13+
14+
if(a < 10)
15+
{
16+
func();
17+
L:
18+
a = 1;
19+
a = 2;
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
CORE
2+
main.c
3+
--dependence-graph --show
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
// Assignment has a control dependency on the first if
8+
\/\/ ([0-9]+).*\n.*IF.*a < 7.*THEN(.*\n)*Control dependencies: (([0-9]+,\1)|(\1,[0-9]+))\n(.*\n){2,3}.*a = 2
9+
// Assignment has a control dependency on the second if
10+
\/\/ ([0-9]+).*\n.*IF.*a < 10.*THEN(.*\n)*Control dependencies: (([0-9]+,\1)|(\1,[0-9]+))\n(.*\n){2,3}.*a = 2
11+
--
12+
^warning: ignoring
13+
--
14+
The first regex above matches output portions like shown below (with <N> being a
15+
location number). The intention is to check whether the assignment has a control
16+
dependency on the goto statement.
17+
18+
// <N> file main.c line 9 function main
19+
IF a < 7 THEN GOTO 1
20+
...
21+
**** 6 file main.c line 19 function main
22+
Control dependencies: (<N>,...)|(...,<N>)
23+
24+
// 6 file main.c line 19 function main
25+
a = 2;
26+
27+
The second regex above matches output portions like shown below (with <N> being
28+
a location number). The intention is to check whether the assignment has a
29+
control dependency on the goto statement.
30+
31+
// <N> file main.c line 14 function main
32+
IF !(a < 10) THEN GOTO 2
33+
...
34+
**** 6 file main.c line 19 function main
35+
Control dependencies: (<N>,...)|(...,<N>)
36+
37+
// 6 file main.c line 19 function main
38+
a = 2;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
int g_in1, g_in2;
2+
int g_out;
3+
4+
void main(void)
5+
{
6+
int t;
7+
if(g_in1)
8+
{
9+
if(g_in2)
10+
t = 0;
11+
else
12+
t = 1;
13+
14+
g_out = 1; // depends on "if(g_in1)
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CORE
2+
main.c
3+
--show --dependence-graph --text -
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
\/\/ ([0-9]+) file.*\n.*IF.*g_in1.*THEN GOTO(.*\n)*Control dependencies: \1\n\n.*\n.*g_out = 1
8+
--
9+
^warning: ignoring
10+
--
11+
The regex above match output portions like shown below (with <N> being a
12+
location number). The intention is to check whether the assignment has a control
13+
dependency on the goto statement.
14+
15+
// <N> file main.c line 7 function main
16+
IF !(g_in1 != 0) THEN GOTO 3
17+
...
18+
**** 3 file main.c line 9 function main
19+
Control dependencies: <N>
20+
21+
// 3 file main.c line 9 function main
22+
g_out = 1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
int a;
2+
3+
void main(void)
4+
{
5+
int i = 0;
6+
while(i < 10)
7+
{
8+
a = 1;
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
CORE
2+
main.c
3+
--dependence-graph --show
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
// Assignment has a control dependency on the loop head
8+
\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1
9+
// Backedge has a control dependency on the loop head
10+
\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}\s*GOTO [0-9]+
11+
// Loop head has a control dependency on itself
12+
Control dependencies: ([0-9]+)\n(.*\n)?\n.*\/\/ \1.*\n.*IF.*i < 10.*THEN
13+
--
14+
^warning: ignoring
15+
--
16+
The first regex above match output portions like shown below (with <N> being a
17+
location number). The intention is to check whether the assignment has a control
18+
dependency on the loop head.
19+
20+
// <N> file main.c line 6 function main
21+
1: IF !(i < 10) THEN GOTO 2
22+
...
23+
**** 3 file main.c line 8 function main
24+
Control dependencies: <N>
25+
26+
// 3 file main.c line 8 function main
27+
a = 1;
28+
29+
The second regex above match output portions like shown below (with <N> being a
30+
location number). The intention is to check whether the backwards goto has a
31+
control dependency on the loop head.
32+
33+
// <N> file main.c line 6 function main
34+
1: IF !(i < 10) THEN GOTO 2
35+
...
36+
**** 4 file main.c line 6 function main
37+
Control dependencies: <N>
38+
39+
// 4 file main.c line 6 function main
40+
GOTO 1
41+
42+
The third regex above match output portions like shown below (with <N> being a
43+
location number). The intention is to check whether the loop head has a control
44+
dependency on itself.
45+
46+
Control dependencies: <N>
47+
Data dependencies: 1
48+
49+
// <N> file main.c line 6 function main
50+
1: IF !(i < 10) THEN GOTO 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
int a;
2+
3+
void main(void)
4+
{
5+
int i = 0;
6+
while(i < 10)
7+
{
8+
if(i < 7)
9+
{
10+
a = 1;
11+
}
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
CORE
2+
main.c
3+
--dependence-graph --show
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
// Assignment has a control dependency on the if
8+
\/\/ ([0-9]+).*\n.*IF.*i < 7.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1
9+
// If has a control dependency on the loop head
10+
\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*i < 7
11+
--
12+
^warning: ignoring
13+
// Assignment does not have a control dependency on the loop head
14+
\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1
15+
--
16+
The first regex above matches output portions like shown below (with <N> being a
17+
location number). The intention is to check whether the assignment has a control
18+
dependency on the if.
19+
20+
// <N> file main.c line 6 function main
21+
1: IF !(i < 7) THEN GOTO 2
22+
...
23+
**** 3 file main.c line 8 function main
24+
Control dependencies: <N>
25+
26+
// 3 file main.c line 8 function main
27+
a = 1;
28+
29+
The second regex above matches output portions like shown below (with <N> being
30+
a location number). The intention is to check whether the if has a control
31+
dependency on the loop head.
32+
33+
// <N> file main.c line 6 function main
34+
1: IF !(i < 10) THEN GOTO 3
35+
36+
**** 3 file main.c line 8 function main
37+
Control dependencies: <N>
38+
Data dependencies: 1
39+
40+
// 3 file main.c line 8 function main
41+
IF !(i < 7) THEN GOTO 2
42+
43+
The third regex above matches output portions like shown below (with <N> being a
44+
location number). The intention is to check that the assignment does not have a
45+
control dependency on the loop head.
46+
47+
// <N> file main.c line 6 function main
48+
1: IF !(i < 10) THEN GOTO 3
49+
...
50+
**** 4 file main.c line 10 function main
51+
Control dependencies: <N>
52+
53+
// 4 file main.c line 10 function main
54+
a = 1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
int a;
2+
3+
void main(void)
4+
{
5+
int i = 0;
6+
7+
if(i < 10)
8+
{
9+
if(i < 7)
10+
{
11+
a = 1;
12+
}
13+
14+
a = 2;
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
CORE
2+
main.c
3+
--dependence-graph --show
4+
activate-multi-line-match
5+
EXIT=0
6+
SIGNAL=0
7+
// Second assignment has a control dependency on the outer if
8+
\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 2
9+
--
10+
^warning: ignoring
11+
// Second assignment does not have a control dependency on the inner if
12+
\/\/ ([0-9]+).*\n.*IF.*i < 7.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 2
13+
--
14+
The first regex above matches output portions like shown below (with <N> being a
15+
location number). The intention is to check whether the assignment has a control
16+
dependency on the outer if.
17+
18+
// <N> file main.c line 7 function main
19+
IF !(i < 10) THEN GOTO 2
20+
...
21+
**** 6 file main.c line 14 function main
22+
Control dependencies: <N>
23+
24+
// 6 file main.c line 14 function main
25+
a = 2;
26+
27+
The second regex above matches output portions like shown below (with <N> being
28+
a location number). The intention is to check that the assignment does not have
29+
a control dependency on the inner if.
30+
31+
// <N> file main.c line 9 function main
32+
IF !(i < 7) THEN GOTO 1
33+
...
34+
**** 6 file main.c line 14 function main
35+
Control dependencies: <N>
36+
37+
// 6 file main.c line 14 function main
38+
a = 2;

0 commit comments

Comments
 (0)