diff mbox

Fix PR 49671 volatile goes missing after inlining

Message ID CA+=Sn1nERzf3wFVRWWakTOTFc7LohHa655us6GNMoPcMtO34Tw@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski July 26, 2011, 5:28 a.m. UTC
On Mon, Jul 25, 2011 at 2:05 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Mon, Jul 25, 2011 at 1:34 AM, Andrew Pinski <pinskia@gmail.com> wrote:
>> Hi,
>>  There are two issues, first the inliner does not copy a volatile
>> when creating a new tree in one case.  The second issue is that
>> IPA-SRA does not check if we are deferencing a pointer variable via a
>> volatile type.
>>
>> OK?  Bootstrapped and tested on x86_64-linux-gnu with no regressions.
>
> Ok.
>
> Can you add a testcase?

Yes Here are the testcases I added:

Thanks,
Andrew Pinski
diff mbox

Patch

Index: testsuite/gcc.dg/tree-ssa/pr49671-1.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr49671-1.c	(revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr49671-1.c	(revision 0)
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" }  */
+volatile int t;
+static inline int cvmx_atomic_get32(volatile int *ptr)
+{
+    return *ptr;
+}
+void f(void)
+{
+  while (!cvmx_atomic_get32(&t))
+    ;
+}
+
+/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
+
Index: testsuite/gcc.dg/tree-ssa/pr49671-2.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/pr49671-2.c	(revision 0)
+++ testsuite/gcc.dg/tree-ssa/pr49671-2.c	(revision 0)
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" }  */
+int t;
+static inline int cvmx_atomic_get32(int *ptr)
+{
+    return *(volatile int*)ptr;
+}
+void f(void)
+{
+  while (!cvmx_atomic_get32(&t))
+    ;
+}
+
+/* { dg-final { scan-tree-dump "\{v\}" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
+