[PATCH] Fix ICE with -fgnu-tm and pragma ivdep (PR middle-end/64391)
Marek Polacek
polacek@redhat.com
Tue Jan 13 16:33:00 GMT 2015
We ICE on this testcase, because the usage of #pragma GCC ivdep
pulls in the ANNOTATE internal functions which don't have underlying
fndecls, hence we segv on a NULL_TREE. This patch makes get_attrs_for
be prepared for such a scenario. The callers of get_attrs_for already
check for NULL_TREE. I don't think internal fns can have transaction_*
attributes anyway. While at it, I did some cleanups.
Bootstrapped/regtested on {ppc64,x86_64}-linux, ok for trunk?
2015-01-13 Marek Polacek <polacek@redhat.com>
PR middle-end/64391
* trans-mem.c (get_attrs_for): Return NULL_TREE if X is NULL_TREE.
* gcc.dg/tm/pr64391.c: New test.
diff --git gcc/testsuite/gcc.dg/tm/pr64391.c gcc/testsuite/gcc.dg/tm/pr64391.c
index e69de29..235118a 100644
--- gcc/testsuite/gcc.dg/tm/pr64391.c
+++ gcc/testsuite/gcc.dg/tm/pr64391.c
@@ -0,0 +1,10 @@
+/* PR middle-end/64391 */
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+void
+foo (void)
+{
+#pragma GCC ivdep
+ while (1);
+}
diff --git gcc/trans-mem.c gcc/trans-mem.c
index b449760..21fa497 100644
--- gcc/trans-mem.c
+++ gcc/trans-mem.c
@@ -183,6 +183,9 @@ static void *expand_regions (struct tm_region *,
static tree
get_attrs_for (const_tree x)
{
+ if (x == NULL_TREE)
+ return NULL_TREE;
+
switch (TREE_CODE (x))
{
case FUNCTION_DECL:
@@ -191,16 +194,16 @@ get_attrs_for (const_tree x)
default:
if (TYPE_P (x))
- return NULL;
+ return NULL_TREE;
x = TREE_TYPE (x);
if (TREE_CODE (x) != POINTER_TYPE)
- return NULL;
+ return NULL_TREE;
/* FALLTHRU */
case POINTER_TYPE:
x = TREE_TYPE (x);
if (TREE_CODE (x) != FUNCTION_TYPE && TREE_CODE (x) != METHOD_TYPE)
- return NULL;
+ return NULL_TREE;
/* FALLTHRU */
case FUNCTION_TYPE:
Marek
More information about the Gcc-patches
mailing list