From patchwork Mon Dec 13 15:20:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [trans-mem] mark _ITM_cxa_throw and _ITM_cxa_allocate_exception as pure Date: Mon, 13 Dec 2010 05:20:10 -0000 From: Aldy Hernandez X-Patchwork-Id: 75364 Message-Id: <4D0639AA.9020605@redhat.com> To: Richard Henderson , gcc-patches@gcc.gnu.org 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. 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); } }