On Wed, Jan 24, 2018 at 11:41:45AM +0100, Tom de Vries wrote: > +/* Insert a dummy ptx insn when encountering a branch to a label with no ptx > + insn inbetween the branch and the label. This works around a JIT bug > + observed at driver version 384.111, at -O0 for sm_50. */ > + > +static void > +prevent_branch_around_nothing (void) > +{ > + rtx_insn *seen_label = 0; > + for (rtx_insn *insn = get_insns (); insn; insn = NEXT_INSN (insn)) > + { > + if (seen_label == 0) > + { > + if (INSN_P (insn) && condjump_p (insn)) > + seen_label = label_ref_label (nvptx_condjump_label (insn, false)); > + > + continue; > + } > + > + if (NOTE_P (insn)) > + continue;
I'm afraid for review I don't know the backend enough. I'd just suggest using NULL instead of 0 for pointers, i.e. clearing seen_label or comparisons of seen_label against NULL, and wonder if DEBUG_INSNs are guaranteed not to appear here. If not, you'd need to skip them too. Jakub