[PATCH] Teach IfConversion about register mask kills

Pete Cooper peter_cooper at apple.com
Fri May 1 16:14:55 PDT 2015


Hi Quentin/Andy

When the if converter predicates an instruction, UpdatePredRedefs can add implicit uses to an instruction.  However, that code was not aware of register masks, unlike StepForward() which it references in its header.

The problem case we have here is something like

R0 = …
if fails stack check, jump to fail, else end

fail:
call ___stack_chk_fail <regmask clobbers R0>
// no return here, so no successors

end:
call free(R0)

Because the stack_chk_fail call doesn’t return, the live range for the R0 def wasn’t live across the ‘fail’ BB, so it was safe to use R0 here, despite the clobber.  After we flatten however, we have something like

R0 = …
call ___stack_chk_fail <regmask clobbers R0>
call free(R0)

so now the use of R0 fails the verifier because R0 was clobbered by the predicated call.

I discussed this with Quentin offline and we agreed that removing R0 from the regmask is definitely not a possibility as later code such as the post-RA scheduler could depend on it for correctness.

Quentin suggested instead that we add imp uses/defs to the call to show that we know a register was live across it, and we’re ok with it.  This then passes the verifier.

Cheers
Pete

-------------- next part --------------
A non-text attachment was scrubbed...
Name: regmask-ifcvt.diff
Type: application/octet-stream
Size: 3327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150501/24803a8e/attachment.obj>


More information about the llvm-commits mailing list