diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-01-26 01:32:35 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-09-27 02:17:31 +0200 |
| commit | 62308ab6a6025f8df926b8af009f68fbebe040b6 (patch) | |
| tree | b10a0f0132827654957be3562495336142e4626a /validation/eval | |
| parent | d765800ade9ccb195c1b45033573dcaeec4e3f46 (diff) | |
| download | sparse-dev-62308ab6a6025f8df926b8af009f68fbebe040b6.tar.gz | |
asm: add test evaluation, expansion & linearization of ASM operands
ASM statements are quite complex.
Add some tests to catch some potential errors.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/eval')
| -rw-r--r-- | validation/eval/asm-degen.c | 37 | ||||
| -rw-r--r-- | validation/eval/asm-memop.c | 48 |
2 files changed, 85 insertions, 0 deletions
diff --git a/validation/eval/asm-degen.c b/validation/eval/asm-degen.c new file mode 100644 index 00000000..5f319159 --- /dev/null +++ b/validation/eval/asm-degen.c @@ -0,0 +1,37 @@ +#ifdef __CHECKER__ +#define __percpu __attribute__((noderef)) +#else +#define __percpu +#endif + +static __percpu int var; +static __percpu int arr[4]; + +static void foo(void) +{ + asm("" :: "r" (var)); +} + +static void bar(void) +{ + asm("" :: "r" (arr)); +} + +static void baz(void) +{ + asm("" :: "m" (var)); +} + +static void qux(void) +{ + asm("" :: "m" (arr)); +} + +/* + * check-name: asm-degen + * check-known-to-fail + * + * check-error-start +eval/asm-degen.c:12:24: warning: dereference of noderef expression + * check-error-end + */ diff --git a/validation/eval/asm-memop.c b/validation/eval/asm-memop.c new file mode 100644 index 00000000..9bbb3a30 --- /dev/null +++ b/validation/eval/asm-memop.c @@ -0,0 +1,48 @@ +extern int g; + +void fo0(int *p) { asm volatile ("op %0" :: "p" (&g)); } +void fo1(int *p) { asm volatile ("op %0" :: "m" (g)); } + +void fo2(int *p) { asm volatile ("op %0" :: "p" (p)); } +void fo3(int *p) { asm volatile ("op %0" :: "m" (*p)); } + +/* + * check-name: eval-asm-memop + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-start +fo0: +.L0: + <entry-point> + asm "op %0" + in: "p" (g) + ret + + +fo1: +.L2: + <entry-point> + asm "op %0" + in: "m" (g) + ret + + +fo2: +.L4: + <entry-point> + asm "op %0" + in: "p" (%arg1) + ret + + +fo3: +.L6: + <entry-point> + asm "op %0" + in: "m" (%arg1) + ret + + + * check-output-end + */ |
