From: H.J. Lu Date: Sun, 8 Jun 2025 06:23:09 +0000 (+0800) Subject: mcore: Don't use gen_rtx_MEM on __attribute__((dllimport)) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11059b4a4e8d4a19e7b554817f7cf0f68e3d54bb;p=thirdparty%2Fgcc.git mcore: Don't use gen_rtx_MEM on __attribute__((dllimport)) On mcore-elf, mcore_mark_dllimport generated (gdb) call debug_tree (decl) > HI size unit-size align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe981f000 arg-types > pointer_to_this > addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_not_align:0 context attributes > (mem:SI (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) [0 S4 A32]) chain > 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) > HI size unit-size align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffe981f000 arg-types > pointer_to_this > addressable used public external decl_5 SI /tmp/x.c:1:40 align:16 warn_if_not_align:0 context attributes > (mem:SI (symbol_ref:SI ("@i.__imp_f1")) [0 S4 A32]) chain > (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 --- diff --git a/gcc/config/mcore/mcore.cc b/gcc/config/mcore/mcore.cc index cd5f2c526490..c4fc145a47ad 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; }