[PATCH] [RegisterScavenger] Fix handling of predicated instructions

Tobias Edler von Koch tobias at codeaurora.org
Fri Jun 5 16:10:38 PDT 2015


On Fri, 5 Jun 2015 15:55:16 -0700 Quentin Colombet
<qcolombet at apple.com> wrote:

> 
> Hold on, isn’t the change you are proposing supposed to allow that, i.e., reuse a register after it has a kill flag set?
> 
> I.e., this patch creates the very case I was saying is broken and that the verifier won’t complain about.
> 
> Consider:
> 
> BB1
> a =
> <predicate> = a<kill>
> <predicate> return
> 
> BB2 <livein a>
> = a
> 
> With your change, the scavenger would be allowed to do:
> BB1
> a =
> <predicate> = a<kill>
> <predicate> return
> // Reuse a
> BB2 <livein a>
> = a <— a is wrong now.
> 

Right, sorry, I see what you're saying now. Thanks for clarifying!

The problem is that currently it will do:

BB1
 a =
 <predicate> = a<kill>
 <predicate> return
 // Spill a  <-- not legal per the verifier, because a is killed
 // Reuse a
 // Reload a

BB2 <livein a>
= a 

So then there are two solutions to fix the bug
a) Figure out whether if conversion really doesn't set kill flags
   correctly - any other passes that might be affected? If the flags
   really are wrong, this should be fixed.
b) Never scavenge a register that's killed by a predicated
   instruction... I guess this would be OK as work-around.

Tobias

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project.




More information about the llvm-commits mailing list