https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94233

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-03-20

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
>   get_object_alignment_1 (base, &bit_base_alignment, &bit_base_misalignment);
>   gcc_assert (bit_base_alignment % BITS_PER_UNIT == 0
>               && bit_base_misalignment % BITS_PER_UNIT == 0);
> where base is the result of get_inner_reference.  This possibly hints at
> some odd alignment values on some decl(?).

Indeed, bit_base_alignment is here == 1; the alignment is:
  ((unsigned)1) << ((NODE)->decl_common.align - 1
hence,  …->decl_common.align == 1

The align:1 is produced by lto.c's offload_handle_link_vars(), which calls:
  tree link_ptr_var = make_node (VAR_DECL);
which contains:
  enum tree_code_class type = TREE_CODE_CLASS (code);
...
  switch (type)
...
    case tcc_declaration:
...
            SET_DECL_ALIGN (t, 1);


Untested patch:

diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 39bb5f45c95..812dcc39b44 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -568,2 +568,3 @@ offload_handle_link_vars (void)
        SET_DECL_MODE (link_ptr_var, TYPE_MODE (type));
+       SET_DECL_ALIGN (field, TYPE_ALIGN (ptr_type_node));
        DECL_SIZE (link_ptr_var) = TYPE_SIZE (type);

Reply via email to