This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug c++/46269] [trans-mem] internal compiler error in expand_block_tm of trans-mem.c
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: rth at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 10 Nov 2010 16:43:51 -0500
- Subject: Re: [Bug c++/46269] [trans-mem] internal compiler error in expand_block_tm of trans-mem.c
- References: <bug-46269-1652@http.gcc.gnu.org/bugzilla/> <bug-46269-1652-3dLmBWa8em@http.gcc.gnu.org/bugzilla/>
The following patch fixes the referenced PR. The problem is an ICE on
an asm statement brought in by inlining. Richard suggested we go into
serial irrevocable before the asm.
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46269
>
> --- Comment #4 from Richard Henderson <rth at gcc dot gnu.org> 2010-11-09 18:06:35 UTC ---
> Since updateBuildingSite is transaction_callable, not
> transaction_safe, we should handle this no matter how
> the other functions are annotated.
>
> When atomic_exchange_and_add is not annotated, we should
> transition to serial-irrevocable mode before the asm,
> just as we would do when calling any other unknown function.
>
> When atomic_exchange_and_add is annotated pure, we should
> believe it and not process anything inside. We do not
> currently support a general TM escape mechanism on a per-
> block basis, so the only way to really ignore stuff inside
> transaction_pure functions is to *not* inline them.
That sounds too easy. You mean like this?
I didn't update the edges because I see we don't do so either for the
GIMPLE_CALL case above (in expand_call_tm). I always get confused
whether I should update the edges or not.
Tested on x86-64 Linux. Ok for branch?
PR/46269
* trans-mem.c (expand_block_tm): Handle GIMPLE_ASM.
Index: testsuite/g++.dg/tm/pr46269.C
===================================================================
--- testsuite/g++.dg/tm/pr46269.C (revision 0)
+++ testsuite/g++.dg/tm/pr46269.C (revision 0)
@@ -0,0 +1,30 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+static inline void atomic_exchange_and_add()
+{
+ __asm__ ("blah");
+}
+
+template<class T> class shared_ptr
+{
+public:
+ shared_ptr( T * p )
+ {
+ atomic_exchange_and_add();
+ }
+};
+
+class BuildingCompletedEvent
+{
+ public:
+ __attribute__((transaction_callable)) void updateBuildingSite(void);
+ __attribute__((transaction_pure)) BuildingCompletedEvent();
+};
+
+void BuildingCompletedEvent::updateBuildingSite(void)
+{
+ shared_ptr<BuildingCompletedEvent> event(new BuildingCompletedEvent());
+}
+
Index: trans-mem.c
===================================================================
--- trans-mem.c (revision 166496)
+++ trans-mem.c (working copy)
@@ -2196,7 +2196,14 @@ expand_block_tm (struct tm_region *regio
break;
case GIMPLE_ASM:
- gcc_unreachable ();
+ {
+ gimple g;
+ g = gimple_build_call (built_in_decls[BUILT_IN_TM_IRREVOCABLE], 0);
+ gimple_set_location (g, gimple_location (stmt));
+ gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+ transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE);
+ break;
+ }
default:
break;