volatile loads must not be simplified
commit0ee83ccffa3437fa97058c7cdc28961f59476c9d
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Wed, 4 Jan 2017 03:03:18 +0000 (4 04:03 +0100)
committerChristopher Li <sparse@chrisli.org>
Mon, 13 Feb 2017 01:34:45 +0000 (13 09:34 +0800)
tree93777aa6faa33beb7890058fea927cbea890bae6
parentd8ce303b14f6c7e0c9f0ec37781404d735476d62
volatile loads must not be simplified

memops.c:simplify_loads() tries to simplify all loads,
even volatile ones.
For example, on the following code:
static int foo(volatile int *a, int v)
{
*a = v;
return *a;
}

test-linearize returns something like:
foo:
store.32    %arg2 -> 0[%arg1]
ret.32      %arg2

while the correct output is more like:
foo:
store.32    %arg2 -> 0[%arg1]
load.32     %r5 <- 0[%arg1]
ret.32      %r5

The fix is to simply ignore loads with the 'volatile' modifier.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
memops.c
validation/memops-volatile.c [new file with mode: 0644]