diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-06 05:02:56 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-01 00:18:44 +0200 |
| commit | b8c17466f25794ff9bf444f058cadf637745a02d (patch) | |
| tree | 7e12e80b149f0e1e5d4e1c0dbf2e8c51810cea24 | |
| parent | 11380d396ac94f6c808f130268c4ac026ac19f14 (diff) | |
| download | sparse-dev-b8c17466f25794ff9bf444f058cadf637745a02d.tar.gz | |
testsuite: improve mem2reg testcases
A few tests are added, some have been renamed to better
refect their purposes. Finally, some checks have been added
or tweaked.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
19 files changed, 178 insertions, 18 deletions
diff --git a/validation/crash-select.c b/validation/crash-select.c new file mode 100644 index 00000000..cec00baf --- /dev/null +++ b/validation/crash-select.c @@ -0,0 +1,18 @@ +struct s { + void *b; + long c; +}; + +long d(void); +static long f(void) +{ + struct s s; + s.c = d(); + if (s.c) + s.c = 2; + return s.c; +} + +/* + * check-name: crash-select + */ diff --git a/validation/alias-distinct.c b/validation/mem2reg/alias-distinct.c index 42937b24..42937b24 100644 --- a/validation/alias-distinct.c +++ b/validation/mem2reg/alias-distinct.c diff --git a/validation/alias-mixed.c b/validation/mem2reg/alias-mixed.c index 0cfbe36b..0cfbe36b 100644 --- a/validation/alias-mixed.c +++ b/validation/mem2reg/alias-mixed.c diff --git a/validation/alias-same.c b/validation/mem2reg/alias-same.c index 55cf4244..55cf4244 100644 --- a/validation/alias-same.c +++ b/validation/mem2reg/alias-same.c diff --git a/validation/mem2reg/cond-expr.c b/validation/mem2reg/cond-expr.c index f38564ef..8acb00ac 100644 --- a/validation/mem2reg/cond-expr.c +++ b/validation/mem2reg/cond-expr.c @@ -10,4 +10,5 @@ int foo(int a, int b, int c) * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file * check-output-ignore * check-output-pattern(2): phi\\. + * check-output-pattern(3): phisrc\\. */ diff --git a/validation/mem2reg/cond-expr5.c b/validation/mem2reg/cond-expr5.c index 6c1e1c34..62ac6c15 100644 --- a/validation/mem2reg/cond-expr5.c +++ b/validation/mem2reg/cond-expr5.c @@ -11,8 +11,12 @@ int foo(int p, int q, int a) /* * check-name: cond-expr5 * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file + * check-known-to-fail + * * check-output-ignore * check-output-excludes: load\\. * check-output-excludes: store\\. - * check-output-pattern(2): phi\\. + * check-output-excludes: phi\\..*, .*, .* + * check-output-pattern(3): phi\\. + * check-output-pattern(5): phisrc\\. */ diff --git a/validation/mem2reg/init-global-array.c b/validation/mem2reg/init-global-array.c index aea4135a..51ca50e3 100644 --- a/validation/mem2reg/init-global-array.c +++ b/validation/mem2reg/init-global-array.c @@ -1,8 +1,11 @@ -struct { +struct s { int a[2]; -} s; +}; -int sarray(void) + +static struct s s; + +static int sarray(void) { s.a[1] = 1; return s.a[1]; @@ -10,8 +13,9 @@ int sarray(void) /* * check-name: init global array - * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file + * check-command: test-linearize $file * check-output-ignore * check-output-excludes: load\\. * check-output-pattern(1): store\\. + * check-output-pattern(1): ret.32 *\\$1 */ diff --git a/validation/mem2reg/init-local-array.c b/validation/mem2reg/init-local-array.c index 2ac53bc7..639a74f1 100644 --- a/validation/mem2reg/init-local-array.c +++ b/validation/mem2reg/init-local-array.c @@ -1,25 +1,28 @@ -int array(void) +static int array(void) { int a[2]; a[1] = 1; + a[0] = 0; return a[1]; } -int sarray(void) +static int sarray(void) { struct { int a[2]; } s; s.a[1] = 1; + s.a[0] = 0; return s.a[1]; } /* * check-name: init local array - * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file + * check-command: test-linearize $file * check-output-ignore - * check-output-excludes: load\\. - * check-output-excludes: store\\. + * check-output-excludes: load + * check-output-excludes: store + * check-output-pattern(2): ret.32 *\\$1 */ diff --git a/validation/mem2reg/loop02-global.c b/validation/mem2reg/loop02-global.c index a0a8b42b..b627b33d 100644 --- a/validation/mem2reg/loop02-global.c +++ b/validation/mem2reg/loop02-global.c @@ -16,7 +16,7 @@ int foo(void) /* * check-name: loop02 global - * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file + * check-command: test-linearize -Wno-decl $file * check-output-ignore * check-output-excludes: load\\. */ diff --git a/validation/mem2reg/missing-return.c b/validation/mem2reg/missing-return.c new file mode 100644 index 00000000..06f6e4d5 --- /dev/null +++ b/validation/mem2reg/missing-return.c @@ -0,0 +1,34 @@ +int f1(void) +{ + if (1) + return 1; +} + +int f0(void) +{ + if (0) + return 0; +} + +int fx(int p) +{ + if (p) + return 0; +} + +int bar(int p) +{ + if (p) + return 0; + p++; +} + +/* + * check-name: missing-return + * check-command: test-linearize -m32 -fdump-ir=mem2reg -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-pattern(1): ret.32 *\\$1 + * check-output-pattern(3): ret.32 *UNDEF + */ diff --git a/validation/reload-aliasing.c b/validation/mem2reg/reload-aliasing.c index 3aad317b..3aad317b 100644 --- a/validation/reload-aliasing.c +++ b/validation/mem2reg/reload-aliasing.c diff --git a/validation/mem2reg/store-deadborn.c b/validation/mem2reg/store-deadborn.c new file mode 100644 index 00000000..cca34d59 --- /dev/null +++ b/validation/mem2reg/store-deadborn.c @@ -0,0 +1,9 @@ +static void foo(int a) +{ + return; + a = 0; +} + +/* + * check-name: store-deadborn + */ diff --git a/validation/linear/stray-phisrc.c b/validation/mem2reg/stray-phisrc.c index e9f35c89..e9f35c89 100644 --- a/validation/linear/stray-phisrc.c +++ b/validation/mem2reg/stray-phisrc.c diff --git a/validation/mem2reg/struct.c b/validation/mem2reg/struct.c new file mode 100644 index 00000000..13962a8e --- /dev/null +++ b/validation/mem2reg/struct.c @@ -0,0 +1,32 @@ +struct s { + int a; + int b; +}; + +int f0(void) +{ + struct s s; + + s.a = 0; + s.b = 1; + + return s.a; +} + +int f1(void) +{ + struct s s; + + s.a = 1; + s.b = 0; + + return s.b; +} + +/* + * check-name: struct + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-pattern(2): ret.32 *\\$0 + */ diff --git a/validation/mem2reg/undef00.c b/validation/mem2reg/undef00.c index ba9ba915..27f0aaa8 100644 --- a/validation/mem2reg/undef00.c +++ b/validation/mem2reg/undef00.c @@ -1,14 +1,22 @@ -void bad0(void) +static int badr(void) { int *a; - *a++; + return *a; +} + +static void badw(int v) +{ + int *a; + *a = v; } /* * check-name: undef00 - * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file + * check-command: test-linearize -fdump-ir=mem2reg $file * check-known-to-fail * check-output-ignore * check-output-pattern(1): load\\. * check-output-pattern(1): load\\..*\\[UNDEF\\] + * check-output-pattern(1): store\\. + * check-output-pattern(1): store\\..*\\[UNDEF\\] */ diff --git a/validation/mem2reg/undef01.c b/validation/mem2reg/undef01.c new file mode 100644 index 00000000..985c73d6 --- /dev/null +++ b/validation/mem2reg/undef01.c @@ -0,0 +1,16 @@ +static void foo(void) +{ + int *b; + for (;;) + *b++ = 0; +} + +/* + * check-name: undef01 + * check-command: sparse -Wmaybe-uninitialized $file + * check-known-to-fail + * + * check-error-start +crazy04.c:3:13: warning: variable 'b' may be uninitialized + * check-error-end + */ diff --git a/validation/mem2reg/unused-var.c b/validation/mem2reg/unused-var.c new file mode 100644 index 00000000..ac394582 --- /dev/null +++ b/validation/mem2reg/unused-var.c @@ -0,0 +1,23 @@ +int foo(int a) +{ + switch (a) { + int u = 1; + + default: + return a; + } +} + +/* + * check-name: unused-var + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +foo: +.L0: + <entry-point> + ret.32 %arg1 + + + * check-output-end + */ diff --git a/validation/mem2reg/killed-insn.c b/validation/optim/killed-insn.c index adbef980..d1cdd02e 100644 --- a/validation/mem2reg/killed-insn.c +++ b/validation/optim/killed-insn.c @@ -1,14 +1,13 @@ -static int g; -static void foo(void) +static void foo(int v) { int a[2] = { }; a; - a[1] = g; + a[1] = v; } /* * check-name: killed-insn - * check-command: test-linearize -fdump-ir=mem2reg $file + * check-command: test-linearize $file * * check-output-ignore * check-output-excludes: store\\. diff --git a/validation/optim/null-phi.c b/validation/optim/null-phi.c new file mode 100644 index 00000000..1f9de4d5 --- /dev/null +++ b/validation/optim/null-phi.c @@ -0,0 +1,9 @@ +static int foo(void) +{ + if (0) + return 0; +} + +/* + * check-name: null-phi + */ |
