Re: sel-sched: fix UB in init_regs_for_mode [PR100311]

2021-04-28 Thread Jakub Jelinek via Gcc-patches
On Wed, Apr 28, 2021 at 03:06:53PM +0100, Richard Earnshaw wrote: > We could of course, change the patch below into a checking assert of the > inverse condition: that would help to catch issues like this. I have nothing against an assert, but am not sure that sel-sched is the best spot for that,

Re: sel-sched: fix UB in init_regs_for_mode [PR100311]

2021-04-28 Thread Richard Earnshaw via Gcc-patches
On 28/04/2021 12:22, Jakub Jelinek via Gcc-patches wrote: On Wed, Apr 28, 2021 at 12:04:45PM +0100, Richard Earnshaw wrote: init_regs_for_mode iterates over all hard regs for the machine to test if the reg is OK for the mode, but an arithmetic overflow can lead to testing elements beyond the

Re: sel-sched: fix UB in init_regs_for_mode [PR100311]

2021-04-28 Thread Jakub Jelinek via Gcc-patches
On Wed, Apr 28, 2021 at 12:04:45PM +0100, Richard Earnshaw wrote: > init_regs_for_mode iterates over all hard regs for the machine to test if > the reg is OK for the mode, but an arithmetic overflow can lead to testing > elements beyond the end of the arrays allocated for fixed and global >

sel-sched: fix UB in init_regs_for_mode [PR100311]

2021-04-28 Thread Richard Earnshaw via Gcc-patches
init_regs_for_mode iterates over all hard regs for the machine to test if the reg is OK for the mode, but an arithmetic overflow can lead to testing elements beyond the end of the arrays allocated for fixed and global registers. Clearly, if a mode requiring multiple hard regs needs one beyond