Patchwork [trans-mem] mark _ITM_cxa_throw and _ITM_cxa_allocate_exception as pure

login
register
mail settings
Submitter Aldy Hernandez
Date Dec. 13, 2010, 3:20 p.m.
Message ID <4D0639AA.9020605@redhat.com>
Download mbox | patch
Permalink /patch/75364/
State New
Headers show

Comments

Aldy Hernandez - Dec. 13, 2010, 3:20 p.m.
Both of these are handled by the runtime, and should be TM pure.  
Otherwise throwing won't work, even with our fancy 
_ITM_cxa_throw/_ITM_cxa_allocate_exception functions.

OK for branch?
libitm/
	* libitm.h (_ITM_cxa_allocate_exception): Mark as pure.
	(_ITM_cxa_throw): Same.
gcc/
	PR/46300
	* cp/except.c (do_allocate_exception): Set transaction_pure
	attribute for _ITM_cxa_allocate_exception.
	(build_throw): Set transaction_pure attribute for _ITM_cxa_throw.
Aldy Hernandez - Dec. 13, 2010, 5:13 p.m.
On 12/13/10 16:20, Aldy Hernandez wrote:
> Both of these are handled by the runtime, and should be TM pure.  
> Otherwise throwing won't work, even with our fancy 
> _ITM_cxa_throw/_ITM_cxa_allocate_exception functions.
>
> OK for branch?
>
rth approved off-list with the exception of the library bits.

Committing.

Patch

Index: libitm/libitm.h
===================================================================
--- libitm/libitm.h	(revision 166496)
+++ libitm/libitm.h	(working copy)
@@ -278,8 +278,8 @@  extern void *_ITM_getTMCloneSafe (void *
 extern void _ITM_registerTMCloneTable (void *, size_t);
 extern void _ITM_deregisterTMCloneTable (void *);
 
-extern void *_ITM_cxa_allocate_exception (size_t);
-extern void _ITM_cxa_throw (void *obj, void *tinfo, void *dest);
+extern void *_ITM_cxa_allocate_exception (size_t) ITM_PURE;
+extern void _ITM_cxa_throw (void *obj, void *tinfo, void *dest) ITM_PURE;
 extern void *_ITM_cxa_begin_catch (void *exc_ptr);
 extern void _ITM_cxa_end_catch (void);
 extern void _ITM_commitTransactionEH(void *exc_ptr) ITM_REGPARM;
Index: gcc/testsuite/g++.dg/tm/pr46300.C
===================================================================
--- gcc/testsuite/g++.dg/tm/pr46300.C	(revision 0)
+++ gcc/testsuite/g++.dg/tm/pr46300.C	(revision 0)
@@ -0,0 +1,8 @@ 
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+void foo(){
+    __transaction {
+        throw 5;
+    }
+}
Index: gcc/cp/except.c
===================================================================
--- gcc/cp/except.c	(revision 166496)
+++ gcc/cp/except.c	(working copy)
@@ -586,6 +586,7 @@  do_allocate_exception (tree type)
 	  if (!get_global_value_if_present (fn2, &fn2))
 	    fn2 = declare_nothrow_library_fn (fn2, ptr_type_node,
 					      size_type_node);
+	  apply_tm_attr (fn2, get_identifier ("transaction_pure"));
 	  record_tm_replacement (fn, fn2);
 	}
     }
@@ -729,6 +730,7 @@  build_throw (tree exp)
 	      tree fn2 = get_identifier ("_ITM_cxa_throw");
 	      if (!get_global_value_if_present (fn2, &fn2))
 		fn2 = push_throw_library_fn (fn2, tmp);
+	      apply_tm_attr (fn2, get_identifier ("transaction_pure"));
 	      record_tm_replacement (fn, fn2);
 	    }
 	}