aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-12-22 09:47:22 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2020-12-23 17:32:52 +0100
commitfeb3c40c8ee043cc893410c9985926439292caee (patch)
treef01493c8c69af1fc5536d5b08c1b3f38d052e874 /gcc
parent16929214fd139c9d092f9bfbd9d8287d5903f593 (diff)
downloadgcc-feb3c40c8ee043cc893410c9985926439292caee.zip
gcc-feb3c40c8ee043cc893410c9985926439292caee.tar.gz
gcc-feb3c40c8ee043cc893410c9985926439292caee.tar.bz2
d: Force TYPE_MODE of classes and non-POD structs as BLKmode
Without this being forced, the optimizer could still make decisions that require objects of the non-POD types to need a temporary, which would result in an ICE during the expand to RTL passes. gcc/d/ChangeLog: PR d/98427 * types.cc (TypeVisitor::visit (TypeStruct *)): Set TYPE_MODE of all non-trivial types as BLKmode. (TypeVisitor::visit (TypeClass *)): Likewise. gcc/testsuite/ChangeLog: PR d/98427 * gdc.dg/pr98427.d: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/d/types.cc10
-rw-r--r--gcc/testsuite/gdc.dg/pr98427.d23
2 files changed, 31 insertions, 2 deletions
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index 94aa1f6..acb8c40 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -964,7 +964,10 @@ public:
if (!t->sym->isPOD ())
{
for (tree tv = t->ctype; tv != NULL_TREE; tv = TYPE_NEXT_VARIANT (tv))
- TREE_ADDRESSABLE (tv) = 1;
+ {
+ TREE_ADDRESSABLE (tv) = 1;
+ SET_TYPE_MODE (tv, BLKmode);
+ }
}
}
@@ -999,7 +1002,10 @@ public:
/* Classes only live in memory, so always set the TREE_ADDRESSABLE bit. */
for (tree tv = basetype; tv != NULL_TREE; tv = TYPE_NEXT_VARIANT (tv))
- TREE_ADDRESSABLE (tv) = 1;
+ {
+ TREE_ADDRESSABLE (tv) = 1;
+ SET_TYPE_MODE (tv, BLKmode);
+ }
/* Type is final, there are no derivations. */
if (t->sym->storage_class & STCfinal)
diff --git a/gcc/testsuite/gdc.dg/pr98427.d b/gcc/testsuite/gdc.dg/pr98427.d
new file mode 100644
index 0000000..225db8b
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr98427.d
@@ -0,0 +1,23 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98427
+// { dg-do compile }
+// { dg-options "-O2 -fno-inline" }
+
+@trusted memoizeExpr()
+{
+ struct CodepointSet
+ {
+ struct CowArray
+ {
+ uint *ptr;
+ }
+
+ const CodepointSet binary(U)(U rhs)
+ {
+ return rhs;
+ }
+
+ CowArray array;
+ }
+
+ CodepointSet().binary(CodepointSet());
+}