From 0095a95a31bb0acd57ce91b55c53a5d95de775d2 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Wed, 18 Mar 2020 16:30:18 +0100 Subject: add testcases for OP_UNREACH Signed-off-by: Luc Van Oostenryck --- validation/context-unreachable.c | 16 ++++++++++++++++ validation/linear/builtin_unreachable.c | 31 ------------------------------- validation/linear/builtin_unreachable0.c | 28 ++++++++++++++++++++++++++++ validation/linear/builtin_unreachable1.c | 31 +++++++++++++++++++++++++++++++ validation/linear/noreturn-unreachable0.c | 23 +++++++++++++++++++++++ 5 files changed, 98 insertions(+), 31 deletions(-) create mode 100644 validation/context-unreachable.c delete mode 100644 validation/linear/builtin_unreachable.c create mode 100644 validation/linear/builtin_unreachable0.c create mode 100644 validation/linear/builtin_unreachable1.c create mode 100644 validation/linear/noreturn-unreachable0.c diff --git a/validation/context-unreachable.c b/validation/context-unreachable.c new file mode 100644 index 00000000..3e330403 --- /dev/null +++ b/validation/context-unreachable.c @@ -0,0 +1,16 @@ +int fun(void); + +static void foo(void) +{ + __context__(1); + if (!fun()) { + __builtin_unreachable(); + return; + } + __context__(-1); +} + +/* + * check-name: context-unreachable + * check-known-to-fail + */ diff --git a/validation/linear/builtin_unreachable.c b/validation/linear/builtin_unreachable.c deleted file mode 100644 index 4f13b892..00000000 --- a/validation/linear/builtin_unreachable.c +++ /dev/null @@ -1,31 +0,0 @@ -void function_that_never_returns(void); - -int foo(int c) -{ - if (c) - return 1; - function_that_never_returns(); - __builtin_unreachable(); -} - -/* - * check-name: __builtin_unreachable() - * check-command: test-linearize -Wno-decl $file - * - * check-known-to-fail - * check-output-start -foo: -.L0: - - cbr %arg1, .L3, .L2 - -.L2: - call function_that_never_returns - unreach - -.L3: - ret.32 $1 - - - * check-output-end - */ diff --git a/validation/linear/builtin_unreachable0.c b/validation/linear/builtin_unreachable0.c new file mode 100644 index 00000000..f9703079 --- /dev/null +++ b/validation/linear/builtin_unreachable0.c @@ -0,0 +1,28 @@ +int foo(int p) +{ + if (p == 3) + __builtin_unreachable(); + return p; +} + +/* + * check-name: builtin_unreachable0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-start +foo: +.L0: + + seteq.32 %r2 <- %arg1, $3 + cbr %r2, .L1, .L3 + +.L1: + unreachable + +.L3: + ret.32 %arg1 + + + * check-output-end + */ diff --git a/validation/linear/builtin_unreachable1.c b/validation/linear/builtin_unreachable1.c new file mode 100644 index 00000000..4dedfaba --- /dev/null +++ b/validation/linear/builtin_unreachable1.c @@ -0,0 +1,31 @@ +void die(void); + +int foo(int c) +{ + if (c) + return 1; + die(); + __builtin_unreachable(); +} + +/* + * check-name: builtin_unreachable1 + * check-command: test-linearize -Wno-decl $file + * + * check-known-to-fail + * check-output-start +foo: +.L0: + + cbr %arg1, .L3, .L2 + +.L3: + ret.32 $1 + +.L2: + call die + unreachable + + + * check-output-end + */ diff --git a/validation/linear/noreturn-unreachable0.c b/validation/linear/noreturn-unreachable0.c new file mode 100644 index 00000000..47bd6aa3 --- /dev/null +++ b/validation/linear/noreturn-unreachable0.c @@ -0,0 +1,23 @@ +extern void die(void) __attribute__((noreturn)); + +int foo(void) +{ + die(); + return 0; +} + +/* + * check-name: noreturn-unreachable0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-start +foo: +.L0: + + call die + unreachable + + + * check-output-end + */ -- cgit 1.2.3-korg