On mcore-elf, mcore_mark_dllimport generated (gdb) call debug_tree (decl) <function_decl 0x7fffe9941200 f1 type <function_type 0x7fffe981f000 type <void_type 0x7fffe98180a8 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7 fffe98180a8 pointer_to_this <pointer_type 0x7fffe9818150>> HI size <integer_cst 0x7fffe9802738 constant 16> unit-size <integer_cst 0x7fffe9802750 constant 2> align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fff e981f000 arg-types <tree_list 0x7fffe980b988 value <void_type 0x7fffe98180a8 void >> pointer_to_this <pointer_type 0x7fffe991b0a8>> addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_no t_align:0 context <translation_unit_decl 0x7fffe9955080 /tmp/x.c> attributes <tree_list 0x7fffe9932708 purpose <identifier_node 0x7fffe9954000 dllimport>> (mem:SI (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) [0 S4 A32]) ch ain <function_decl 0x7fffe9941300 f2>>
which caused: (gdb) bt file=0x2c0f1c8 "/export/gnu/import/git/sources/gcc-test/gcc/calls.cc", line=3746, function=0x2c0f747 "expand_call") at /export/gnu/import/git/sources/gcc-test/gcc/diagnostic.cc:1780 target=0x0, ignore=1) at /export/gnu/import/git/sources/gcc-test/gcc/calls.cc:3746 ... (gdb) call debug_rtx (datum) (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) (gdb) Don't use gen_rtx_MEM in mcore_mark_dllimport to generate (gdb) call debug_tree (fndecl) <function_decl 0x7fffe9941200 f1 type <function_type 0x7fffe981f000 type <void_type 0x7fffe98180a8 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7 fffe98180a8 pointer_to_this <pointer_type 0x7fffe9818150>> HI size <integer_cst 0x7fffe9802738 constant 16> unit-size <integer_cst 0x7fffe9802750 constant 2> align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fff e981f000 arg-types <tree_list 0x7fffe980b988 value <void_type 0x7fffe98180a8 void >> pointer_to_this <pointer_type 0x7fffe991b0a8>> addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_no t_align:0 context <translation_unit_decl 0x7fffe9955080 /tmp/x.c> attributes <tree_list 0x7fffe9932708 purpose <identifier_node 0x7fffe9954000 dllimport>> (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) chain <function_decl 0x 7fffe9941300 f2>> (gdb) instead. This fixes: gcc.c-torture/compile/dll.c -O0 (internal compiler error: in assemble_variable, at varasm.cc:2544) gcc.dg/visibility-12.c (internal compiler error: in expand_call, at calls.cc:3744) for more-elf. PR target/120589 * config/mcore/mcore.cc (mcore_mark_dllimport): Don't use gen_rtx_MEM. -- H.J.
From 27e3d43723fdf68dda1337813826fcfb10ae7468 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.to...@gmail.com> Date: Sun, 8 Jun 2025 14:23:09 +0800 Subject: [PATCH] mcore: Don't use gen_rtx_MEM on __attribute__((dllimport)) On mcore-elf, mcore_mark_dllimport generated (gdb) call debug_tree (decl) <function_decl 0x7fffe9941200 f1 type <function_type 0x7fffe981f000 type <void_type 0x7fffe98180a8 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe98180a8 pointer_to_this <pointer_type 0x7fffe9818150>> HI size <integer_cst 0x7fffe9802738 constant 16> unit-size <integer_cst 0x7fffe9802750 constant 2> align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe981f000 arg-types <tree_list 0x7fffe980b988 value <void_type 0x7fffe98180a8 void>> pointer_to_this <pointer_type 0x7fffe991b0a8>> addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_not_align:0 context <translation_unit_decl 0x7fffe9955080 /tmp/x.c> attributes <tree_list 0x7fffe9932708 purpose <identifier_node 0x7fffe9954000 dllimport>> (mem:SI (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) [0 S4 A32]) chain <function_decl 0x7fffe9941300 f2>> which caused: (gdb) bt file=0x2c0f1c8 "/export/gnu/import/git/sources/gcc-test/gcc/calls.cc", line=3746, function=0x2c0f747 "expand_call") at /export/gnu/import/git/sources/gcc-test/gcc/diagnostic.cc:1780 target=0x0, ignore=1) at /export/gnu/import/git/sources/gcc-test/gcc/calls.cc:3746 ... (gdb) call debug_rtx (datum) (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) (gdb) Don't use gen_rtx_MEM in mcore_mark_dllimport to generate (gdb) call debug_tree (fndecl) <function_decl 0x7fffe9941200 f1 type <function_type 0x7fffe981f000 type <void_type 0x7fffe98180a8 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe98180a8 pointer_to_this <pointer_type 0x7fffe9818150>> HI size <integer_cst 0x7fffe9802738 constant 16> unit-size <integer_cst 0x7fffe9802750 constant 2> align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe981f000 arg-types <tree_list 0x7fffe980b988 value <void_type 0x7fffe98180a8 void>> pointer_to_this <pointer_type 0x7fffe991b0a8>> addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_not_align:0 context <translation_unit_decl 0x7fffe9955080 /tmp/x.c> attributes <tree_list 0x7fffe9932708 purpose <identifier_node 0x7fffe9954000 dllimport>> (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) chain <function_decl 0x7fffe9941300 f2>> (gdb) instead. This fixes: gcc.c-torture/compile/dll.c -O0 (internal compiler error: in assemble_variable, at varasm.cc:2544) gcc.dg/visibility-12.c (internal compiler error: in expand_call, at calls.cc:3744) for more-elf. PR target/120589 * config/mcore/mcore.cc (mcore_mark_dllimport): Don't use gen_rtx_MEM. Signed-off-by: H.J. Lu <hjl.to...@gmail.com> --- gcc/config/mcore/mcore.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gcc/config/mcore/mcore.cc b/gcc/config/mcore/mcore.cc index cd5f2c52649..c4fc145a47a 100644 --- a/gcc/config/mcore/mcore.cc +++ b/gcc/config/mcore/mcore.cc @@ -2984,9 +2984,7 @@ mcore_mark_dllimport (tree decl) /* ??? At least I think that's why we do this. */ idp = get_identifier (newname); - newrtl = gen_rtx_MEM (Pmode, - gen_rtx_SYMBOL_REF (Pmode, - IDENTIFIER_POINTER (idp))); + newrtl = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp)); XEXP (DECL_RTL (decl), 0) = newrtl; } -- 2.49.0