From 1f80dfc0ab201d68ceedbb536196a3384f61c609 Mon Sep 17 00:00:00 2001 From: Daniel Poetzl Date: Wed, 28 Feb 2018 14:58:26 +0000 Subject: [PATCH] More dependence graph tests --- .../goto-analyzer/dependence-graph10/main.c | 15 ++++ .../dependence-graph10/test.desc | 39 +++++++++++ .../goto-analyzer/dependence-graph11/main.c | 15 ++++ .../dependence-graph11/test.desc | 23 +++++++ .../goto-analyzer/dependence-graph12/main.c | 21 ++++++ .../dependence-graph12/test.desc | 38 ++++++++++ .../goto-analyzer/dependence-graph4/main.c | 6 +- .../goto-analyzer/dependence-graph4/test.desc | 69 +++++++++++++++++++ .../goto-analyzer/dependence-graph7/main.c | 10 +++ .../goto-analyzer/dependence-graph7/test.desc | 50 ++++++++++++++ .../goto-analyzer/dependence-graph8/main.c | 13 ++++ .../goto-analyzer/dependence-graph8/test.desc | 54 +++++++++++++++ .../goto-analyzer/dependence-graph9/main.c | 16 +++++ .../goto-analyzer/dependence-graph9/test.desc | 38 ++++++++++ 14 files changed, 404 insertions(+), 3 deletions(-) create mode 100644 regression/goto-analyzer/dependence-graph10/main.c create mode 100644 regression/goto-analyzer/dependence-graph10/test.desc create mode 100644 regression/goto-analyzer/dependence-graph11/main.c create mode 100644 regression/goto-analyzer/dependence-graph11/test.desc create mode 100644 regression/goto-analyzer/dependence-graph12/main.c create mode 100644 regression/goto-analyzer/dependence-graph12/test.desc create mode 100644 regression/goto-analyzer/dependence-graph7/main.c create mode 100644 regression/goto-analyzer/dependence-graph7/test.desc create mode 100644 regression/goto-analyzer/dependence-graph8/main.c create mode 100644 regression/goto-analyzer/dependence-graph8/test.desc create mode 100644 regression/goto-analyzer/dependence-graph9/main.c create mode 100644 regression/goto-analyzer/dependence-graph9/test.desc diff --git a/regression/goto-analyzer/dependence-graph10/main.c b/regression/goto-analyzer/dependence-graph10/main.c new file mode 100644 index 000000000000..8cdfb5e41584 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph10/main.c @@ -0,0 +1,15 @@ +int a; + +void main(void) +{ + int i = 0; + + if(i < 10) + { + a = 1; + } + else + { + a = 2; + } +} diff --git a/regression/goto-analyzer/dependence-graph10/test.desc b/regression/goto-analyzer/dependence-graph10/test.desc new file mode 100644 index 000000000000..e0d118d2ac3d --- /dev/null +++ b/regression/goto-analyzer/dependence-graph10/test.desc @@ -0,0 +1,39 @@ +CORE +main.c +--dependence-graph --show +activate-multi-line-match +EXIT=0 +SIGNAL=0 +// First assignment has a control dependency on the if +\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1 +// Second assignment has a control dependency on the if +\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 2 +-- +^warning: ignoring +-- +The first regex above matches output portions like shown below (with being a +location number). The intention is to check whether the assignment has a control +dependency on the goto statement. + + // file main.c line 7 function main + IF !(i < 10) THEN GOTO 1 + +**** 3 file main.c line 9 function main +Control dependencies: + + // 3 file main.c line 9 function main + a = 1; + +The second regex above matches output portions like shown below (with being +a location number). The intention is to check whether the assignment has a +control dependency on the goto statement. + + // file main.c line 7 function main + IF !(i < 10) THEN GOTO 1 +... +**** 5 file main.c line 13 function main +Control dependencies: + + // 5 file main.c line 13 function main + 1: a = 2; + diff --git a/regression/goto-analyzer/dependence-graph11/main.c b/regression/goto-analyzer/dependence-graph11/main.c new file mode 100644 index 000000000000..c3ab582f6763 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph11/main.c @@ -0,0 +1,15 @@ +int a; + +void func() +{ +} + +void main(void) +{ + func(); + + if(a < 10) + { + a = 1; + } +} diff --git a/regression/goto-analyzer/dependence-graph11/test.desc b/regression/goto-analyzer/dependence-graph11/test.desc new file mode 100644 index 000000000000..9f5d6031cf30 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph11/test.desc @@ -0,0 +1,23 @@ +CORE +main.c +--dependence-graph --show +activate-multi-line-match +EXIT=0 +SIGNAL=0 +// Assignment has a control dependency on the if +\/\/ ([0-9]+).*\n.*IF.*a < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1 +-- +^warning: ignoring +-- +The regex above match output portions like shown below (with being a +location number). The intention is to check whether the assignment has a control +dependency on the goto statement. + + // file main.c line 11 function main + IF !(i < 10) THEN GOTO 1 +... +**** 3 file main.c line 13 function main +Control dependencies: + + // 3 file main.c line 13 function main + a = 1; diff --git a/regression/goto-analyzer/dependence-graph12/main.c b/regression/goto-analyzer/dependence-graph12/main.c new file mode 100644 index 000000000000..0257cb1f1c53 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph12/main.c @@ -0,0 +1,21 @@ +int a; + +void func() +{ +} + +void main(void) +{ + if(a < 7) + { + goto L; + } + + if(a < 10) + { + func(); + L: + a = 1; + a = 2; + } +} diff --git a/regression/goto-analyzer/dependence-graph12/test.desc b/regression/goto-analyzer/dependence-graph12/test.desc new file mode 100644 index 000000000000..b14ba9f7ba66 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph12/test.desc @@ -0,0 +1,38 @@ +CORE +main.c +--dependence-graph --show +activate-multi-line-match +EXIT=0 +SIGNAL=0 +// Assignment has a control dependency on the first if +\/\/ ([0-9]+).*\n.*IF.*a < 7.*THEN(.*\n)*Control dependencies: (([0-9]+,\1)|(\1,[0-9]+))\n(.*\n){2,3}.*a = 2 +// Assignment has a control dependency on the second if +\/\/ ([0-9]+).*\n.*IF.*a < 10.*THEN(.*\n)*Control dependencies: (([0-9]+,\1)|(\1,[0-9]+))\n(.*\n){2,3}.*a = 2 +-- +^warning: ignoring +-- +The first regex above matches output portions like shown below (with being a +location number). The intention is to check whether the assignment has a control +dependency on the goto statement. + + // file main.c line 9 function main + IF a < 7 THEN GOTO 1 +... +**** 6 file main.c line 19 function main +Control dependencies: (,...)|(...,) + + // 6 file main.c line 19 function main + a = 2; + +The second regex above matches output portions like shown below (with being +a location number). The intention is to check whether the assignment has a +control dependency on the goto statement. + + // file main.c line 14 function main + IF !(a < 10) THEN GOTO 2 +... +**** 6 file main.c line 19 function main +Control dependencies: (,...)|(...,) + + // 6 file main.c line 19 function main + a = 2; diff --git a/regression/goto-analyzer/dependence-graph4/main.c b/regression/goto-analyzer/dependence-graph4/main.c index cad28241847b..9e8e617503d0 100644 --- a/regression/goto-analyzer/dependence-graph4/main.c +++ b/regression/goto-analyzer/dependence-graph4/main.c @@ -3,13 +3,13 @@ int g_out; void main(void) { - int t; + int x; if(g_in1) { if(g_in2) - t = 0; + x = 0; else - t = 1; + x = 1; g_out = 1; // depends on "if(g_in1) } diff --git a/regression/goto-analyzer/dependence-graph4/test.desc b/regression/goto-analyzer/dependence-graph4/test.desc index 8a29e80131d0..05b09668b855 100644 --- a/regression/goto-analyzer/dependence-graph4/test.desc +++ b/regression/goto-analyzer/dependence-graph4/test.desc @@ -5,5 +5,74 @@ activate-multi-line-match EXIT=0 SIGNAL=0 \/\/ ([0-9]+) file.*\n.*IF.*g_in1.*THEN GOTO(.*\n)*Control dependencies: \1\n\n.*\n.*g_out = 1 +\/\/ ([0-9]+) file.*\n.*IF.*g_in2.*THEN GOTO(.*\n)*Control dependencies: \1\n\n.*\n.*x = 0 +\/\/ ([0-9]+) file.*\n.*IF.*g_in2.*THEN GOTO(.*\n)*Control dependencies: \1\n\n.*\n.*x = 1 -- ^warning: ignoring +\/\/ ([0-9]+) file.*\n.*IF.*g_in1.*THEN GOTO(.*\n)*Control dependencies: (([0-9]+,\1)|(\1,[0-9]+)|(\1))\n(.*\n){2,3}.*x = 0 +\/\/ ([0-9]+) file.*\n.*IF.*g_in1.*THEN GOTO(.*\n)*Control dependencies: (([0-9]+,\1)|(\1,[0-9]+)|(\1))\n(.*\n){2,3}.*x = 1 +-- +The first regex above matches output portions like shown below (with being a +location number). The intention is to check whether the assignment has a control +dependency on the goto statement. + + // file main.c line 7 function main + IF !(g_in1 != 0) THEN GOTO 3 +... +**** 3 file main.c line 14 function main +Control dependencies: + + // 3 file main.c line 14 function main + g_out = 1; + +The second regex above matches output portions like shown below (with being +a location number). The intention is to check whether the assignment has a +control dependency on the goto statement. + + // file main.c line 9 function main + IF !(g_in2 != 0) THEN GOTO 3 +... +**** 3 file main.c line 10 function main +Control dependencies: + + // 3 file main.c line 10 function main + x = 0; + +The third regex above matches output portions like shown below (with being +a location number). The intention is to check whether the assignment has a +control dependency on the goto statement. + + // file main.c line 9 function main + IF !(g_in2 != 0) THEN GOTO 3 +... +**** 3 file main.c line 12 function main +Control dependencies: + + // 3 file main.c line 12 function main + x = 1; + +The fourth regex above matches output portions like shown below (with being +a location number). The intention is to check whether the assignment has a +control dependency on the goto statement. + + // file main.c line 7 function main + IF g_in1 != 0 THEN GOTO 2 +... +**** 6 file main.c line 10 function main +Control dependencies: (...,)|(,...)| + + // 6 file main.c line 10 function main + x = 0; + +The fifth regex above matches output portions like shown below (with being +a location number). The intention is to check whether the assignment has a +control dependency on the goto statement. + + // file main.c line 7 function main + IF g_in1 != 0 THEN GOTO 2 +... +**** 6 file main.c line 12 function main +Control dependencies: (...,)|(,...)| + + // 6 file main.c line 12 function main + x = 1; diff --git a/regression/goto-analyzer/dependence-graph7/main.c b/regression/goto-analyzer/dependence-graph7/main.c new file mode 100644 index 000000000000..e0ab2d5b1a4c --- /dev/null +++ b/regression/goto-analyzer/dependence-graph7/main.c @@ -0,0 +1,10 @@ +int a; + +void main(void) +{ + int i = 0; + while(i < 10) + { + a = 1; + } +} diff --git a/regression/goto-analyzer/dependence-graph7/test.desc b/regression/goto-analyzer/dependence-graph7/test.desc new file mode 100644 index 000000000000..62067ef188a6 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph7/test.desc @@ -0,0 +1,50 @@ +CORE +main.c +--dependence-graph --show +activate-multi-line-match +EXIT=0 +SIGNAL=0 +// Assignment has a control dependency on the loop head +\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1 +// Backedge has a control dependency on the loop head +\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}\s*GOTO [0-9]+ +// Loop head has a control dependency on itself +Control dependencies: ([0-9]+)\n(.*\n)?\n.*\/\/ \1.*\n.*IF.*i < 10.*THEN +-- +^warning: ignoring +-- +The first regex above match output portions like shown below (with being a +location number). The intention is to check whether the assignment has a control +dependency on the loop head. + + // file main.c line 6 function main + 1: IF !(i < 10) THEN GOTO 2 +... +**** 3 file main.c line 8 function main +Control dependencies: + + // 3 file main.c line 8 function main + a = 1; + +The second regex above match output portions like shown below (with being a +location number). The intention is to check whether the backwards goto has a +control dependency on the loop head. + + // file main.c line 6 function main + 1: IF !(i < 10) THEN GOTO 2 +... +**** 4 file main.c line 6 function main +Control dependencies: + + // 4 file main.c line 6 function main + GOTO 1 + +The third regex above match output portions like shown below (with being a +location number). The intention is to check whether the loop head has a control +dependency on itself. + +Control dependencies: +Data dependencies: 1 + + // file main.c line 6 function main + 1: IF !(i < 10) THEN GOTO 2 diff --git a/regression/goto-analyzer/dependence-graph8/main.c b/regression/goto-analyzer/dependence-graph8/main.c new file mode 100644 index 000000000000..ca7bf52632fc --- /dev/null +++ b/regression/goto-analyzer/dependence-graph8/main.c @@ -0,0 +1,13 @@ +int a; + +void main(void) +{ + int i = 0; + while(i < 10) + { + if(i < 7) + { + a = 1; + } + } +} diff --git a/regression/goto-analyzer/dependence-graph8/test.desc b/regression/goto-analyzer/dependence-graph8/test.desc new file mode 100644 index 000000000000..09c03bfe871d --- /dev/null +++ b/regression/goto-analyzer/dependence-graph8/test.desc @@ -0,0 +1,54 @@ +CORE +main.c +--dependence-graph --show +activate-multi-line-match +EXIT=0 +SIGNAL=0 +// Assignment has a control dependency on the if +\/\/ ([0-9]+).*\n.*IF.*i < 7.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1 +// If has a control dependency on the loop head +\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*i < 7 +-- +^warning: ignoring +// Assignment does not have a control dependency on the loop head +\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 1 +-- +The first regex above matches output portions like shown below (with being a +location number). The intention is to check whether the assignment has a control +dependency on the if. + + // file main.c line 8 function main + 1: IF !(i < 7) THEN GOTO 2 +... +**** 3 file main.c line 10 function main +Control dependencies: + + // 3 file main.c line 10 function main + a = 1; + +The second regex above matches output portions like shown below (with being +a location number). The intention is to check whether the if has a control +dependency on the loop head. + + // file main.c line 6 function main + 1: IF !(i < 10) THEN GOTO 3 + +**** 3 file main.c line 8 function main +Control dependencies: +Data dependencies: 1 + + // 3 file main.c line 8 function main + IF !(i < 7) THEN GOTO 2 + +The third regex above matches output portions like shown below (with being a +location number). The intention is to check that the assignment does not have a +control dependency on the loop head. + + // file main.c line 6 function main + 1: IF !(i < 10) THEN GOTO 3 +... +**** 4 file main.c line 10 function main +Control dependencies: + + // 4 file main.c line 10 function main + a = 1; diff --git a/regression/goto-analyzer/dependence-graph9/main.c b/regression/goto-analyzer/dependence-graph9/main.c new file mode 100644 index 000000000000..d968c9f55e1c --- /dev/null +++ b/regression/goto-analyzer/dependence-graph9/main.c @@ -0,0 +1,16 @@ +int a; + +void main(void) +{ + int i = 0; + + if(i < 10) + { + if(i < 7) + { + a = 1; + } + + a = 2; + } +} diff --git a/regression/goto-analyzer/dependence-graph9/test.desc b/regression/goto-analyzer/dependence-graph9/test.desc new file mode 100644 index 000000000000..2bcae4642df5 --- /dev/null +++ b/regression/goto-analyzer/dependence-graph9/test.desc @@ -0,0 +1,38 @@ +CORE +main.c +--dependence-graph --show +activate-multi-line-match +EXIT=0 +SIGNAL=0 +// Second assignment has a control dependency on the outer if +\/\/ ([0-9]+).*\n.*IF.*i < 10.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 2 +-- +^warning: ignoring +// Second assignment does not have a control dependency on the inner if +\/\/ ([0-9]+).*\n.*IF.*i < 7.*THEN(.*\n)*Control dependencies: \1\n(.*\n){2,3}.*a = 2 +-- +The first regex above matches output portions like shown below (with being a +location number). The intention is to check whether the assignment has a control +dependency on the outer if. + + // file main.c line 7 function main + IF !(i < 10) THEN GOTO 2 +... +**** 6 file main.c line 14 function main +Control dependencies: + + // 6 file main.c line 14 function main + a = 2; + +The second regex above matches output portions like shown below (with being +a location number). The intention is to check that the assignment does not have +a control dependency on the inner if. + + // file main.c line 9 function main + IF !(i < 7) THEN GOTO 1 +... +**** 6 file main.c line 14 function main +Control dependencies: + + // 6 file main.c line 14 function main + a = 2;