* [PATCH] volatile loads are side-effects too
@ 2017-11-07 15:59 Luc Van Oostenryck
2017-11-07 18:55 ` Christopher Li
0 siblings, 1 reply; 3+ messages in thread
From: Luc Van Oostenryck @ 2017-11-07 15:59 UTC (permalink / raw)
To: linux-sparse; +Cc: Luc Van Oostenryck
Some branch simplifications are only valid if the branch is free
of side-effects. The check is done in flow.c:bb_has_side_effects()
but currently deosn't take in account the fact that a volatile load
is also a side-effect.
Fix this by adding the appropriate check.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
flow.c | 7 +++++++
validation/optim/volatile-side-effect.c | 13 +++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 validation/optim/volatile-side-effect.c
diff --git a/flow.c b/flow.c
index 6b2c879a8..1144bff4e 100644
--- a/flow.c
+++ b/flow.c
@@ -169,6 +169,13 @@ static int bb_has_side_effects(struct basic_block *bb)
/* FIXME! This should take "const" etc into account */
return 1;
+ case OP_LOAD:
+ if (!insn->type)
+ return 1;
+ if (insn->type->ctype.modifiers & MOD_VOLATILE)
+ return 1;
+ continue;
+
case OP_STORE:
case OP_CONTEXT:
return 1;
diff --git a/validation/optim/volatile-side-effect.c b/validation/optim/volatile-side-effect.c
new file mode 100644
index 000000000..842b72282
--- /dev/null
+++ b/validation/optim/volatile-side-effect.c
@@ -0,0 +1,13 @@
+void foo(int p, volatile int *ptr)
+{
+ p ? : *ptr;
+ p ? : *ptr;
+}
+
+/*
+ * check-name: volatile-side-effect
+ * check-command: test-linearize -Wno-decl $file
+ * check-output-ignore
+ *
+ * check-output-pattern(2): load
+ */
--
2.14.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] volatile loads are side-effects too
2017-11-07 15:59 [PATCH] volatile loads are side-effects too Luc Van Oostenryck
@ 2017-11-07 18:55 ` Christopher Li
2017-11-08 8:17 ` Luc Van Oostenryck
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Li @ 2017-11-07 18:55 UTC (permalink / raw)
To: Luc Van Oostenryck; +Cc: Linux-Sparse
On Tue, Nov 7, 2017 at 11:59 PM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> Some branch simplifications are only valid if the branch is free
> of side-effects. The check is done in flow.c:bb_has_side_effects()
> but currently deosn't take in account the fact that a volatile load
> is also a side-effect.
>
> Fix this by adding the appropriate check.
>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Looks good to me.
Chris
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] volatile loads are side-effects too
2017-11-07 18:55 ` Christopher Li
@ 2017-11-08 8:17 ` Luc Van Oostenryck
0 siblings, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2017-11-08 8:17 UTC (permalink / raw)
To: Christopher Li; +Cc: Linux-Sparse
On Wed, Nov 08, 2017 at 02:55:05AM +0800, Christopher Li wrote:
> On Tue, Nov 7, 2017 at 11:59 PM, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> > Some branch simplifications are only valid if the branch is free
> > of side-effects. The check is done in flow.c:bb_has_side_effects()
> > but currently deosn't take in account the fact that a volatile load
> > is also a side-effect.
> >
> > Fix this by adding the appropriate check.
> >
> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
>
> Looks good to me.
Thank you for the review.
Thank you for the very fast review.
-- Luc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-08 8:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 15:59 [PATCH] volatile loads are side-effects too Luc Van Oostenryck
2017-11-07 18:55 ` Christopher Li
2017-11-08 8:17 ` Luc Van Oostenryck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.