Patchwork PR lto/51698 and the state of LTO + transactional memory

login
register
mail settings
Submitter Aldy Hernandez
Date Jan. 25, 2012, 1:36 p.m.
Message ID <4F200554.8070002@redhat.com>
Download mbox | patch
Permalink /patch/137761/
State New
Headers show

Comments

Aldy Hernandez - Jan. 25, 2012, 1:36 p.m.
On 01/24/12 17:24, Richard Henderson wrote:
> On 01/25/2012 10:16 AM, Aldy Hernandez wrote:
>> The attached patch fixes the ICE in the PR, though it won't do what
>> the user ultimately wants to do, given the limitations described.
>> Perhaps we could create another PR and tag it with an enhancement
>> request.
>
> An enhancement request pr sounds good.

Done: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51997

> Ok.

Tests revealed minor mismatches in other parts of the testsuite, which I 
have fixed below.

I would like another approval, just in case you disagree with the way I 
changed the dummy declarations in the LTO testsuite.

Sorry for the noise, I thought I had it all done :).

Tested on x86-64 Linux.
PR lto/51698
	* builtin-types.def: (BT_CONST_DOUBLE_PTR): New.
	(BT_FN_VOID_PTR_CONST_PTR_SIZE): New.
	(BT_FN_VOID_PTR_INT_SIZE): New.
	(BT_FN_UINT_UINT_VAR): Remove.
	(BT_FN_UINT32_UINT32_VAR): New.
	(BT_FN_DOUBLE_VPTR): Remove.
	(BT_FN_DOUBLE_CONST_DOUBLE_PTR): New.
	* gtm-builtins.def (_ITM_abortTransaction): Set return type to
	void.
	(_ITM_changeTransactionMode): Same.
	(_ITM_memmoveRtWt): Change return type to void.
	(_ITM_memcpyRtWt): Same.
	(_ITM_memsetW): Same.
	(_ITM_RaRD): Change types to double.
	(_ITM_RD): Same.
	(_ITM_RaWD): Same.
	(_ITM_RfWD): Same.
	* builtins.def (DEF_TM_BUILTIN): Set BOTH_P to true.
testsuite/
	PR lto/51698
	* gcc.dg/lto/trans-mem-4_0.c: New.
	* gcc.dg/lto/trans-mem-4_1.c: New.
	* gcc.dg/lto/trans-mem-2_0.c: Provide correct argument types for
	TM builtins.
	* gcc.dg/lto/trans-mem-1_0.c: Require stdint_types.
	* gcc.dg/lto/trans-mem-1_1.c: Provide correct argument types for
	TM builtins.
	* gcc.dg/lto/trans-mem-3_0.c: Require stdint_types.
	* gcc.dg/lto/trans-mem-3_1.c: Provide correct argument types for
	TM builtins.
Richard Henderson - Jan. 25, 2012, 8:07 p.m.
On 01/26/2012 12:36 AM, Aldy Hernandez wrote:
> I would like another approval, just in case you disagree with the way I changed the dummy declarations in the LTO testsuite.

Still ok.


r~

Patch

Index: testsuite/gcc.dg/lto/trans-mem-2_0.c
===================================================================
--- testsuite/gcc.dg/lto/trans-mem-2_0.c	(revision 183474)
+++ testsuite/gcc.dg/lto/trans-mem-2_0.c	(working copy)
@@ -1,17 +1,19 @@ 
 /* { dg-lto-options {{-flto -fgnu-tm}} } */
 /* { dg-lto-do link } */
+/* { dg-require-effective-target stdint_types } */
+
+#include <stdint.h>
 
 extern void foobar() __attribute__((transaction_callable));
 
-#define dummy(func) \
-  __attribute__((noinline,noclone,used)) void func() { asm (""); }
+#define noinline __attribute__((noinline,noclone,used))
 
-dummy(_ITM_beginTransaction)
-dummy(_ITM_commitTransaction)
-dummy(_ITM_WU4)
-dummy(_ITM_WU8)
-dummy(_ITM_registerTMCloneTable)
-dummy(_ITM_deregisterTMCloneTable)
+noinline uint32_t _ITM_beginTransaction(uint32_t a, ...) { asm(""); }
+noinline void _ITM_commitTransaction (void) { asm(""); }
+noinline void _ITM_WU4 (void *a, uint32_t b) { asm(""); }
+noinline void _ITM_WU8 (void *a, uint64_t b) { asm(""); }
+noinline void _ITM_registerTMCloneTable (void) { asm(""); }
+noinline void _ITM_deregisterTMCloneTable (void) { asm(""); }
 
 main()
 {
Index: testsuite/gcc.dg/lto/trans-mem-4_0.c
===================================================================
--- testsuite/gcc.dg/lto/trans-mem-4_0.c	(revision 0)
+++ testsuite/gcc.dg/lto/trans-mem-4_0.c	(revision 0)
@@ -0,0 +1,12 @@ 
+/* { dg-lto-options {{-flto -fgnu-tm}} } */
+/* { dg-lto-do link } */
+/* { dg-require-effective-target stdint_types } */
+
+extern void foo() __attribute__((transaction_safe));
+
+int main()
+{
+  __transaction_atomic {
+      foo();
+  }
+}
Index: testsuite/gcc.dg/lto/trans-mem-4_1.c
===================================================================
--- testsuite/gcc.dg/lto/trans-mem-4_1.c	(revision 0)
+++ testsuite/gcc.dg/lto/trans-mem-4_1.c	(revision 0)
@@ -0,0 +1,14 @@ 
+#include <stdint.h>
+
+__attribute__((transaction_safe))
+void foo() 
+{
+}
+
+uint32_t _ITM_beginTransaction(uint32_t prop, ...)
+{
+}
+
+void __builtin__ITM_commitTransaction (void)
+{
+}
Index: testsuite/gcc.dg/lto/trans-mem-1_0.c
===================================================================
--- testsuite/gcc.dg/lto/trans-mem-1_0.c	(revision 183474)
+++ testsuite/gcc.dg/lto/trans-mem-1_0.c	(working copy)
@@ -1,5 +1,6 @@ 
 /* { dg-lto-options {{-flto -fgnu-tm}} } */
 /* { dg-lto-do link } */
+/* { dg-require-effective-target stdint_types } */
 
 int i;
 
Index: testsuite/gcc.dg/lto/trans-mem-3_0.c
===================================================================
--- testsuite/gcc.dg/lto/trans-mem-3_0.c	(revision 183474)
+++ testsuite/gcc.dg/lto/trans-mem-3_0.c	(working copy)
@@ -1,5 +1,6 @@ 
 /* { dg-lto-options {{-flto}} } */
 /* { dg-lto-do link } */
+/* { dg-require-effective-target stdint_types } */
 
 /* Test that we can build one object file with -fgnu-tm
    (trans-mem-3_1.c), but do the final link of all objects without
Index: testsuite/gcc.dg/lto/trans-mem-1_1.c
===================================================================
--- testsuite/gcc.dg/lto/trans-mem-1_1.c	(revision 183474)
+++ testsuite/gcc.dg/lto/trans-mem-1_1.c	(working copy)
@@ -1,9 +1,10 @@ 
-#define dummy(func) \
-  __attribute__((noinline,noclone,used)) void func() { asm (""); }
+#include <stdint.h>
 
-dummy(_ITM_beginTransaction)
-dummy(_ITM_commitTransaction)
-dummy(_ITM_WU4)
-dummy(_ITM_WU8)
-dummy(_ITM_registerTMCloneTable)
-dummy(_ITM_deregisterTMCloneTable)
+#define noinline __attribute__((noinline,noclone,used))
+
+noinline uint32_t _ITM_beginTransaction(uint32_t a, ...) { asm(""); }
+noinline void _ITM_commitTransaction (void) { asm(""); }
+noinline void _ITM_WU4 (void *a, uint32_t b) { asm(""); }
+noinline void _ITM_WU8 (void *a, uint64_t b) { asm(""); }
+noinline void _ITM_registerTMCloneTable (void) { asm(""); }
+noinline void _ITM_deregisterTMCloneTable (void) { asm(""); }
Index: testsuite/gcc.dg/lto/trans-mem-3_1.c
===================================================================
--- testsuite/gcc.dg/lto/trans-mem-3_1.c	(revision 183474)
+++ testsuite/gcc.dg/lto/trans-mem-3_1.c	(working copy)
@@ -1,5 +1,7 @@ 
 /* { dg-options "-fgnu-tm" } */
 
+#include <stdint.h>
+
 extern int i;
 
 main()
@@ -7,12 +9,11 @@  main()
   __transaction_atomic { i = 0; }
 }
 
-#define dummy(func)							\
-  __attribute__((noinline,noclone,used)) void func() { asm (""); }
+#define noinline __attribute__((noinline,noclone,used))
 
-dummy(_ITM_beginTransaction)
-dummy(_ITM_commitTransaction)
-dummy(_ITM_WU4)
-dummy(_ITM_WU8)
-dummy(_ITM_registerTMCloneTable)
-dummy(_ITM_deregisterTMCloneTable)
+noinline uint32_t _ITM_beginTransaction(uint32_t a, ...) { asm(""); }
+noinline void _ITM_commitTransaction (void) { asm(""); }
+noinline void _ITM_WU4 (void *a, uint32_t b) { asm(""); }
+noinline void _ITM_WU8 (void *a, uint64_t b) { asm(""); }
+noinline void _ITM_registerTMCloneTable (void) { asm(""); }
+noinline void _ITM_deregisterTMCloneTable (void) { asm(""); }
Index: builtin-types.def
===================================================================
--- builtin-types.def	(revision 183474)
+++ builtin-types.def	(working copy)
@@ -103,6 +103,10 @@  DEF_PRIMITIVE_TYPE (BT_PTRMODE, (*lang_h
 DEF_PRIMITIVE_TYPE (BT_INT_PTR, integer_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_FLOAT_PTR, float_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_DOUBLE_PTR, double_ptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_CONST_DOUBLE_PTR,
+		    build_pointer_type
+		     (build_qualified_type (double_type_node,
+		     			    TYPE_QUAL_CONST)))
 DEF_PRIMITIVE_TYPE (BT_LONGDOUBLE_PTR, long_double_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_PID, pid_type_node)
 DEF_PRIMITIVE_TYPE (BT_SIZE, size_type_node)
@@ -342,10 +346,14 @@  DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_STR
 		     BT_INT, BT_CONST_STRING, BT_CONST_STRING, BT_SIZE)
 DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_CONST_PTR_SIZE,
 		     BT_PTR, BT_PTR, BT_CONST_PTR, BT_SIZE)
+DEF_FUNCTION_TYPE_3 (BT_FN_VOID_PTR_CONST_PTR_SIZE,
+		     BT_VOID, BT_PTR, BT_CONST_PTR, BT_SIZE)
 DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_PTR_CONST_PTR_SIZE,
 		     BT_INT, BT_CONST_PTR, BT_CONST_PTR, BT_SIZE)
 DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_INT_SIZE,
 		     BT_PTR, BT_PTR, BT_INT, BT_SIZE)
+DEF_FUNCTION_TYPE_3 (BT_FN_VOID_PTR_INT_SIZE,
+		     BT_VOID, BT_PTR, BT_INT, BT_SIZE)
 DEF_FUNCTION_TYPE_3 (BT_FN_VOID_PTR_INT_INT,
 		     BT_VOID, BT_PTR, BT_INT, BT_INT)
 DEF_FUNCTION_TYPE_3 (BT_FN_VOID_CONST_PTR_PTR_SIZE,
@@ -498,8 +506,8 @@  DEF_FUNCTION_TYPE_VAR_1 (BT_FN_VOID_CONS
 			 BT_VOID, BT_CONST_PTR)
 DEF_FUNCTION_TYPE_VAR_1 (BT_FN_INT_CONST_STRING_VAR,
 			 BT_INT, BT_CONST_STRING)
-DEF_FUNCTION_TYPE_VAR_1 (BT_FN_UINT_UINT_VAR,
-			 BT_UINT, BT_UINT)
+DEF_FUNCTION_TYPE_VAR_1 (BT_FN_UINT32_UINT32_VAR,
+			 BT_UINT32, BT_UINT32)
 
 DEF_FUNCTION_TYPE_VAR_2 (BT_FN_INT_FILEPTR_CONST_STRING_VAR,
 			 BT_INT, BT_FILEPTR, BT_CONST_STRING)
@@ -539,7 +547,7 @@  DEF_FUNCTION_TYPE_1 (BT_FN_I2_VPTR, BT_I
 DEF_FUNCTION_TYPE_1 (BT_FN_I4_VPTR, BT_I4, BT_VOLATILE_PTR)
 DEF_FUNCTION_TYPE_1 (BT_FN_I8_VPTR, BT_I8, BT_VOLATILE_PTR)
 DEF_FUNCTION_TYPE_1 (BT_FN_FLOAT_VPTR, BT_FLOAT, BT_VOLATILE_PTR)
-DEF_FUNCTION_TYPE_1 (BT_FN_DOUBLE_VPTR, BT_DOUBLE, BT_VOLATILE_PTR)
+DEF_FUNCTION_TYPE_1 (BT_FN_DOUBLE_CONST_DOUBLE_PTR, BT_DOUBLE, BT_DOUBLE_PTR)
 DEF_FUNCTION_TYPE_1 (BT_FN_LDOUBLE_VPTR, BT_LONGDOUBLE, BT_VOLATILE_PTR)
 
 DEF_FUNCTION_TYPE_2 (BT_FN_VOID_VPTR_I1, BT_VOID, BT_VOLATILE_PTR, BT_I1)
Index: builtins.def
===================================================================
--- builtins.def	(revision 183474)
+++ builtins.def	(working copy)
@@ -147,7 +147,7 @@  along with GCC; see the file COPYING3.
 #undef DEF_TM_BUILTIN
 #define DEF_TM_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,    \
-	       false, true, true, ATTRS, false, flag_tm)
+	       true, true, true, ATTRS, false, flag_tm)
 
 /* Define an attribute list for math functions that are normally
    "impure" because some of them may write into global memory for
Index: gtm-builtins.def
===================================================================
--- gtm-builtins.def	(revision 183474)
+++ gtm-builtins.def	(working copy)
@@ -1,21 +1,21 @@ 
 DEF_TM_BUILTIN (BUILT_IN_TM_START, "_ITM_beginTransaction",
-		BT_FN_UINT_UINT_VAR, ATTR_TM_NOTHROW_RT_LIST)
+		BT_FN_UINT32_UINT32_VAR, ATTR_TM_NOTHROW_RT_LIST)
 
 DEF_TM_BUILTIN (BUILT_IN_TM_COMMIT, "_ITM_commitTransaction",
 		BT_FN_VOID, ATTR_TM_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_COMMIT_EH, "_ITM_commitTransactionEH",
 		BT_FN_VOID_PTR, ATTR_TM_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_ABORT, "_ITM_abortTransaction",
-		BT_FN_INT, ATTR_TM_NORETURN_NOTHROW_LIST)
+		BT_FN_VOID_INT, ATTR_TM_NORETURN_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_IRREVOCABLE, "_ITM_changeTransactionMode",
-		BT_FN_INT_INT, ATTR_TM_NOTHROW_LIST)
+		BT_FN_VOID_INT, ATTR_TM_NOTHROW_LIST)
 
 DEF_TM_BUILTIN (BUILT_IN_TM_MEMCPY, "_ITM_memcpyRtWt",
-		BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_TM_TMPURE_NOTHROW_LIST)
+		BT_FN_VOID_PTR_CONST_PTR_SIZE, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_MEMMOVE, "_ITM_memmoveRtWt",
-		BT_FN_PTR_PTR_CONST_PTR_SIZE, ATTR_TM_TMPURE_NOTHROW_LIST)
+		BT_FN_VOID_PTR_CONST_PTR_SIZE, ATTR_TM_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_MEMSET, "_ITM_memsetW",
-	       	BT_FN_PTR_PTR_INT_SIZE, ATTR_TM_TMPURE_NOTHROW_LIST)
+	       	BT_FN_VOID_PTR_INT_SIZE, ATTR_TM_TMPURE_NOTHROW_LIST)
 
 DEF_TM_BUILTIN (BUILT_IN_TM_GETTMCLONE_IRR, "_ITM_getTMCloneOrIrrevocable",
 		BT_FN_PTR_PTR, ATTR_TM_CONST_NOTHROW_LIST)
@@ -172,13 +172,13 @@  DEF_TM_BUILTIN (BUILT_IN_TM_LOAD_RFW_FLO
 		BT_FN_FLOAT_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
 
 DEF_TM_BUILTIN (BUILT_IN_TM_LOAD_DOUBLE, "_ITM_RD",
-		BT_FN_DOUBLE_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+		BT_FN_DOUBLE_CONST_DOUBLE_PTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOAD_RAR_DOUBLE, "_ITM_RaRD",
-		BT_FN_FLOAT_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+		BT_FN_DOUBLE_CONST_DOUBLE_PTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOAD_RAW_DOUBLE, "_ITM_RaWD",
-		BT_FN_FLOAT_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+		BT_FN_DOUBLE_CONST_DOUBLE_PTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
 DEF_TM_BUILTIN (BUILT_IN_TM_LOAD_RFW_DOUBLE, "_ITM_RfWD",
-		BT_FN_FLOAT_VPTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
+		BT_FN_DOUBLE_CONST_DOUBLE_PTR, ATTR_TM_PURE_TMPURE_NOTHROW_LIST)
 
 /* These stubs should get defined in the backend if applicable.  */
 DEF_BUILTIN_STUB (BUILT_IN_TM_LOAD_M64, "__builtin__ITM_RM64")