https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88001
Bug ID: 88001 Summary: ASMCONS cannot handle properly UNSPEC(CONST) Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: claziss at gmail dot com Target Milestone: --- ASMCONS cannot handle CONST (UNSPEC) properly, leading to a wrong output. I have the following rtl before asmcons pass: (insn 8 13 9 2 (set (reg:SI 157 [ list ]) (asm_operands:SI ("") ("=g") 0 [ (const:SI (unspec:SI [ (symbol_ref:SI ("c_const") [flags 0x2] <var_decl 0x7f6735ad25a0 c_const>) ] ARC_UNSPEC_GOTOFFPC)) ] [ (asm_input:SI ("0") ../t02.c:9) ] [] ../t02.c:9)) ../t02.c:9 -1 (nil)) Asmcons pass leads to this: (insn 13 3 8 2 (set (reg:SI 157 [ list ]) (const:SI (unspec:SI [ (symbol_ref:SI ("c_const") [flags 0x2] <var_decl 0x7fd69f6365a0 c_const>) ] ARC_UNSPEC_GOTOFFPC))) ../t02.c:9 -1 (nil)) (insn 8 13 9 2 (set (reg:SI 157 [ list ]) (asm_operands:SI ("") ("=g") 0 [ (const:SI (unspec:SI [ (symbol_ref:SI ("c_const") [flags 0x2] <var_decl 0x7fd69f6365a0 c_const>) ] ARC_UNSPEC_GOTOFFPC)) ] [ (asm_input:SI ("0") ../t02.c:9) ] [] ../t02.c:9)) ../t02.c:9 -1 (nil)) Which will lead latter on to an ICE when we verify the rtx sharing. My test program is this one, and it needs to be compiled for ARC backend with the following options: -mcpu=archs -O2 -fpic typedef void (*func_ptr) (void); static func_ptr __DTOR_LIST__[1] = { (func_ptr)(-1) }; void foo (int a) { func_ptr *dtor_list; __asm ("" : "=g" (dtor_list) : "0" (__DTOR_LIST__)); dtor_list[a](); }