PR/54893: allow volatiles inside relaxed transactions

Submitted by Aldy Hernandez on Oct. 11, 2012, 8:56 p.m.

Details

Message ID 50773295.7000005@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Oct. 11, 2012, 8:56 p.m.
Apparently we were a bit too aggressive on disallowing volatiles inside 
transactions.  Torvald seems to agree that volatiles should be allowed 
inside relaxed transactions, since they will go into serial irrevocable 
mode anyhow.

The following patch fixes the PR.

I did not include a test that fails on a volatile in an atomic 
transaction because there is already one in the testsuite.

OK pending tests?
PR middle-end/54893
	* trans-mem.c (diagnose_tm_1_op): Allow volatiles inside relaxed
	transactions.

Comments

Richard Henderson Oct. 11, 2012, 9:15 p.m.
On 10/11/2012 01:56 PM, Aldy Hernandez wrote:
> 	PR middle-end/54893
> 	* trans-mem.c (diagnose_tm_1_op): Allow volatiles inside relaxed
> 	transactions.

Ok.

r~

Patch hide | download patch | download mbox

diff --git a/gcc/testsuite/c-c++-common/tm/pr54893.c b/gcc/testsuite/c-c++-common/tm/pr54893.c
new file mode 100644
index 0000000..df26f25
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/tm/pr54893.c
@@ -0,0 +1,13 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+/* Test that volatiles are allowed inside relaxed transactions.  */
+
+volatile int test_var = 0;
+
+int main()
+{
+  __transaction_relaxed {
+    test_var++;
+  }
+}
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index ef384ac..dc08bc6 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -561,7 +561,7 @@  diagnose_tm_1_op (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
   if ((code == VAR_DECL
        || code == RESULT_DECL
        || code == PARM_DECL)
-      && d->block_flags & (DIAG_TM_SAFE | DIAG_TM_RELAXED)
+      && d->block_flags & DIAG_TM_SAFE
       && TREE_THIS_VOLATILE (TREE_TYPE (*tp))
       && !d->saw_volatile)
     {