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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|120763                      |

--- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> ---


The combination of -fPIC and -mexplicit-relocs is crucial to tripping this bug.
 That combination turns jumps from forms like this:


(jump_insn/j 34 28 29 7 (set (pc)
        (label_ref:SI 13)) 443 {jump}
     (nil)
 -> 13)

Into a form like this:


(insn 34 28 35 7 (set (reg:SI 15 a5 [141])
        (unspec:SI [
                (label_ref:SI 13)
                (const_int 1 [0x1])
                (pc)
            ] UNSPEC_AUIPC)) 268 {auipcsi}
     (expr_list:REG_EQUAL (unspec:SI [
                (label_ref:SI 13)
                (const_int 1 [0x1])
                (pc)
            ] UNSPEC_AUIPC)
        (insn_list:REG_LABEL_OPERAND 13 (nil))))
(insn 35 34 36 7 (set (reg:SI 15 a5 [141])
        (lo_sum:SI (reg:SI 15 a5 [141])
            (symbol_ref:SI (".LA1") [flags 0x2]))) 270 {*lowsi}
     (expr_list:REG_EQUAL (label_ref:SI 13)
        (nil)))
(jump_insn/j 36 35 29 7 (set (pc)
        (reg:SI 15 a5 [141])) 444 {indirect_jumpsi}
     (nil)
 -> 13)

In the former form it's trivial to redirect the jump, for the latter is notably
more complex.

Jump redirection is critical for shrink-wrapping as we have a block (bb4) that
needs a prologue.  We create a new block for the prologue (bb9) and we want to
redirect a jump to bb4 to instead jump to bb9.

Of course the jumps reaching bb4 have the complex form above.  So simple
methods to change the jump fail.  The last-ditch attempt uses an API that
assumes the jump we're changing is a fallthru path -- which is not the case
here we trigger an assertion.


Given this is dependent upon -mexplicit-relocs and nobody's using that in
practice as far as I know, I'm not going to spend further time on this problem
in the immediate future.  I guess someone could add a diagnostic to the RISC-V
backend to indicate that explicit-relocs+PIC+reorder-blocks-and-partition isn't
supported.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120763
[Bug 120763] [meta-bug] Tracker for bugs to visit during weekly RISC-V meeting

Reply via email to