This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR 49671 volatile goes missing after inlining
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:
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" } } */
+
+
Thanks,
Andrew Pinski