[LLVMdev] SwitchInstr::removeCase() doesn't remove PHINodes' predecessors

Nick Lewycky nicholas at mxc.ca
Fri Sep 26 23:44:25 PDT 2008


Nuno Lopes wrote:
> PHINode should have one entry for each predecessor of its parent basic 
> block!
>         %ret.0 = phi i32 [ 0, %ifthen ], [ 1, %ifelse ]         ; <i32> 
> [#uses=1]
> Broken module found, compilation aborted!
> 
> This is because myphi is not reachable from ifthen anymore. My question is: 
> is this a bug (or missing feature) or do I need to take care of the PHI 
> Nodes myself?

You get to take care of it yourself.

  If it is the later what's the best way to handle that? (from
> what I could see I would need to iterate over all the instructions in the 
> target BB and fix PHI Nodes if the target block becomes unreachable).

TargetBB->removePredecessor(SwitchBB). Note that you should call this 
before you call removeCase!

Nick



More information about the llvm-dev mailing list