This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] D support for S/390
On March 19, 2019 1:07:26 PM GMT+01:00, Robin Dapp <rdapp@linux.ibm.com> wrote:
>Hi,
>
>> Alignment is written to TypeInfo, I don't think it should ever be
>> zero. That would mean that it isn't being generated by the compiler,
>> or read by the library correctly, so something else is amiss.
>
>it took me a while to see that in libphobos/libdruntime/object.d
>
>override @property size_t talign() nothrow pure const {return m_align;}
>
>returns a size_t but m_align is a uint. The type info seems to be
>stored in memory by the compiler and writes a GCC "sizetype".
It should probably use sth specified by the C ABI instead, like using size_type_node which maps to the targets size_t rather than the internal sizetype.
When
>using it, we only emit a 4-byte read which loads the first half of the
>stored 8 bytes. This will work on a little-endian machine but fail on
>big endian.
>
>I'd hope it is safe to change m_align's type to size_t since, as far as
>I can tell, the compiler will always write 8 bytes and the memory
>layout
>will not be changed by that.
>
>Does this [1] look reasonable?
>
>Regards
> Robin
>
>---
>
>[1]
>diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
>index dac66acdcd4..1bd94c33e82 100644
>--- a/gcc/d/typeinfo.cc
>+++ b/gcc/d/typeinfo.cc
>@@ -954,7 +954,7 @@ public:
> StructFlags m_flags;
> void function(void*) xdtor;
> void function(void*) xpostblit;
>- uint m_align;
>+ size_t m_align;
> version (X86_64)
> TypeInfo m_arg1;
> TypeInfo m_arg2;
>@@ -1032,7 +1032,7 @@ public:
> else
> this->layout_field (null_pointer_node);
>
>- /* uint m_align; */
>+ /* size_t m_align; */
> this->layout_field (size_int (ti->alignsize ()));
>
> if (global.params.is64bit)
>diff --git a/libphobos/libdruntime/object.d
>b/libphobos/libdruntime/object.d
>index 38bd0ae1f6b..bb821bf7040 100644
>--- a/libphobos/libdruntime/object.d
>+++ b/libphobos/libdruntime/object.d
>@@ -1226,7 +1226,7 @@ class TypeInfo_Struct : TypeInfo
> }
> void function(void*) xpostblit;
>
>- uint m_align;
>+ size_t m_align;
>
>override @property immutable(void)* rtInfo() const { return m_RTInfo; }