Inlining problems again

Johannes Pfau nospam at example.com
Sat Apr 5 04:41:06 PDT 2014


Am Sat, 5 Apr 2014 07:37:00 +0100
schrieb Iain Buclaw <ibuclaw at gdcproject.org>:
> 
> Reason for no inline is "mismatched arguments" - which means that the
> caller and callee disagree on the arguments to pass to the function.
> The fix is to make sure that caller and callee arguments match when
> generating the function on both sides.  We could prevent this from
> recurring by putting in an assert in the codegen.

Root cause is that const(char)[] is a distinct type compared to char[]
so I think we need to make const(char)[] a variant of char[].

We could use build_variant_type_copy and then modify the copy
to use the correct basetype. Here's a proof of concept, could you finish
this Iain?

(We should probably check all types which have a 'next' type if a
similar change makes sense for these)

--- a/gcc/d/d-ctype.cc
+++ b/gcc/d/d-ctype.cc
@@ -496,6 +496,21 @@ TypeDArray::toCtype (void)
          ctype = castMod(0)->toCtype();
          ctype = insert_type_modifiers (ctype, mod);
        }
+      else if (!next->isNaked())
+       {
+         tree ptrtype = next->toCtype();
+         Type *dt = new TypeDArray(next->castMod(0));
+         dt = dt->semantic(Loc(NULL, 0), NULL);
+         ctype = build_variant_type_copy(dt->toCtype());
+
+         //tree f1 = build_decl (BUILTINS_LOCATION, FIELD_DECL,
get_identifier ("ptr"), build_pointer_type (ptrtype));
+         //DECL_CONTEXT (f1) = ctype;
+         //TREE_CHAIN (f1) = NULL_TREE;
+         //TREE_CHAIN (TYPE_FIELDS (ctype)) = f1;
+
+         TYPE_LANG_SPECIFIC (ctype) = build_d_type_lang_specific
(this);
+         d_keep (ctype);
+       }
       else
        {
          tree lentype = Type::tsize_t->toCtype();



More information about the D.gnu mailing list