https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90000
Will Schmidt <willschm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |willschm at gcc dot gnu.org --- Comment #2 from Will Schmidt <willschm at gcc dot gnu.org> --- Debug dump. Testcase looks like so: void foo (void) { register float __attribute__ ((mode(SD))) r31 __asm__ ("r31"); register float __attribute__ ((mode(SD))) fr1 __asm__ ("fr1"); __asm__ ("#" : "=d" (fr1)); r31 = fr1; __asm__ ("#" : : "r" (r31)); } # When we reach function.c: instantiate_virtual_regs_in_insn() -> error_for_asm(), pcfun looks like so. Breakpoint 12, error_for_asm (insn=0x200000710340, gmsgid=0x1195d100 "impossible constraint in %<asm%>") at rtl-error.c:82 82 va_start (ap, gmsgid); foo () { (note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (note 2 3 5 2 NOTE_INSN_FUNCTION_BEG) (insn 5 2 6 2 (parallel [ (set (reg/v:SD 33 1 [ fr1 ]) (asm_operands:SD ("#") ("=d") 0 [] [] [] /tmp/pr60032.c:10)) (clobber (reg:SI 98 ca)) ]) "/tmp/pr60032.c":10:3 -1 (nil)) (insn 6 5 7 2 (set (subreg:SI (reg:SD 117 [ fr1.0_1 ]) 0) (subreg:SI (reg/v:SD 33 1 [ fr1 ]) 0)) "/tmp/pr60032.c":11:7 -1 (nil)) (insn 7 6 8 2 (set (reg:SI 30 30 [ r31 ]) (subreg:SI (reg:SD 117 [ fr1.0_1 ]) 0)) "/tmp/pr60032.c":11:7 -1 (nil)) (insn 8 7 0 2 (parallel [ (asm_operands/v ("#") ("") 0 [ (reg/v:SD 30 30 [ r31 ]) ] [ (asm_input:SD ("r") /tmp/pr60032.c:12) ] [] /tmp/pr60032.c:12) (clobber (reg:SI 98 ca)) ]) "/tmp/pr60032.c":12:3 -1 (nil)) } # The error is reported: /tmp/pr60032.c: In function 'foo': /tmp/pr60032.c:10:3: error: impossible constraint in 'asm' 10 | __asm__ ("#" : "=d" (fr1)); | ^~~~~~~ "..."84 va_end (ap); # set a break at the subsequent call into delete_insn(). 0x000000001063486c <+2268>: cmpwi r9,10 0x0000000010634870 <+2272>: beq 0x10634e5c <(anonymous namespace)::pass_instantiate_virtual_regs::execute(function*)+3788> => 0x0000000010634874 <+2276>: mr r3,r31 0x0000000010634878 <+2280>: bl 0x1041d528 <delete_insn(rtx_insn*)+8> 0x000000001063487c <+2284>: nop (gdb) break * 0x000000001063487c Breakpoint 15 at 0x1063487c: file function.c, line 1796. (gdb) c Continuing. "..." Breakpoint 15, 0x000000001063487c in instantiate_virtual_regs_in_insn (insn=0x200000710340) at function.c:1796 1796 delete_insn (insn); (gdb) p insn $7 = (rtx_insn *) 0x200000710340 (gdb) pr insn warning: Expression is not an assignment (and might have no effect) (insn/v 5 2 6 2 (parallel [ (set (reg/v:SD 33 1 [ fr1 ]) (asm_operands:SD ("#") ("=d") 0 [] [] [] /tmp/pr60032.c:10)) (clobber (reg:SI 98 ca)) ]) "/tmp/pr60032.c":10:3 -1 (nil)) (gdb) # And we can see via pcfun that the instruction (#5) has been removed. (gdb) pcfun foo () { (note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (note 2 3 6 2 NOTE_INSN_FUNCTION_BEG) (insn 6 2 7 2 (set (subreg:SI (reg:SD 117 [ fr1.0_1 ]) 0) (subreg:SI (reg/v:SD 33 1 [ fr1 ]) 0)) "/tmp/pr60032.c":11:7 -1 (nil)) (insn 7 6 8 2 (set (reg:SI 30 30 [ r31 ]) (subreg:SI (reg:SD 117 [ fr1.0_1 ]) 0)) "/tmp/pr60032.c":11:7 -1 (nil)) (insn 8 7 0 2 (parallel [ (asm_operands/v ("#") ("") 0 [ (reg/v:SD 30 30 [ r31 ]) ] [ (asm_input:SD ("r") /tmp/pr60032.c:12) ] [] /tmp/pr60032.c:12) (clobber (reg:SI 98 ca)) ]) "/tmp/pr60032.c":12:3 -1 (nil)) } ( When we get to lra, we are spinning in the loop lra_init_equiv (); for (;;) { for (;;) { bool reloads_p = lra_constraints (lra_constraint_iter == 0); ... lra_eliminate (false, false); ... # backtrace and assorted debug shows we are repeatedly emitting an instruction via emit_move_insn down this call path: #0 emit_move_insn (x=0x20000065ed48, y=0x20000065ac80) at expr.c:3804 #1 0x000000001085f7bc in lra_emit_move (x=0x20000065ed48, y=<optimized out>) at lra.c:499 #2 0x000000001087cf5c in curr_insn_transform (check_only_p=check_only_p@entry=0x0) at lra-constraints.c:4425 #3 0x000000001087ec00 in lra_constraints (first_p=<optimized out>) at lra-constraints.c:5025 #4 0x0000000010860518 in lra (f=<optimized out>) at lra.c:2437 #5 0x00000000107ffdec in do_reload () at ira.c:5523 And our pcfun output shows we are continuing to insert a (pair?) of insn entries. foo () { (note 3 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (note 2 3 38 2 NOTE_INSN_FUNCTION_BEG) (insn 38 2 39 2 (set (mem/c:SI (plus:DI (reg/f:DI 110 sfp) (const_int 80 [0x50])) [1 %sfp+80 S4 A32]) (subreg:SI (reg/v:SD 33 1 [ fr1 ]) 0)) "/tmp/pr60032.c":11:7 492 {*movsi_internal1} (expr_list:REG_DEAD (reg:DI 33 1) (nil))) (insn 39 38 36 2 (set (subreg:SI (reg/v:SD 142 [ fr1 ]) 0) (mem/c:SI (plus:DI (reg/f:DI 110 sfp) (const_int 80 [0x50])) [1 %sfp+80 S4 A32])) "/tmp/pr60032.c":11:7 492 {*movsi_internal1} (expr_list:REG_DEAD (reg:SI 143) (nil))) ... (insn 14 17 15 2 (set (mem/c:SI (plus:DI (reg/f:DI 110 sfp) (const_int 32 [0x20])) [1 %sfp+32 S4 A32]) (subreg:SI (reg/v:SD 120 [ fr1 ]) 0)) "/tmp/pr60032.c":11:7 492 {*movsi_internal1} (expr_list:REG_DEAD (reg/v:SD 120 [ fr1 ]) (nil))) (insn 15 14 6 2 (set (subreg:SI (reg/v:SD 118 [ fr1 ]) 0) (mem/c:SI (plus:DI (reg/f:DI 110 sfp) (const_int 32 [0x20])) [1 %sfp+32 S4 A32])) "/tmp/pr60032.c":11:7 492 {*movsi_internal1} (nil)) (insn 6 15 7 2 (set (mem/c:SI (plus:DI (reg/f:DI 110 sfp) (const_int 32 [0x20])) [1 %sfp+32 S4 A32]) (subreg:SI (reg/v:SD 118 [ fr1 ]) 0)) "/tmp/pr60032.c":11:7 492 {*movsi_internal1} (expr_list:REG_DEAD (reg/v:SD 118 [ fr1 ]) (nil))) (insn 7 6 8 2 (set (reg:SI 30 30 [ r31 ]) (mem/c:SI (plus:DI (reg/f:DI 110 sfp) (const_int 32 [0x20])) [1 %sfp+32 S4 A32])) "/tmp/pr60032.c":11:7 492 {*movsi_internal1} (nil)) (insn 8 7 11 2 (parallel [ (asm_operands/v ("#") ("") 0 [ (reg/v:SD 30 30 [ r31 ]) ] [ (asm_input:SD ("r") /tmp/pr60032.c:12) ] [] /tmp/pr60032.c:12) (clobber (reg:SI 98 ca)) ]) "/tmp/pr60032.c":12:3 -1 (expr_list:REG_DEAD (reg/v:SD 30 30 [ r31 ]) (expr_list:REG_UNUSED (reg:SI 98 ca) (nil)))) (note 11 8 12 3 [bb 3] NOTE_INSN_BASIC_BLOCK) (insn 12 11 13 3 (unspec [ (const_int 0 [0]) ] UNSPEC_NOP) "/tmp/pr60032.c":13:1 829 {nop} (nil)) }