static void purgeBlockFromPHIs(BasicBlock source,BasicBlock target){
  for (Enumeration<Instruction> e=target.forwardRealInstrEnumerator(); e.hasMoreElements(); ) {
    Instruction s=e.nextElement();
    if (s.operator() != PHI)     return;
    int numPairs=Phi.getNumberOfPreds(s);
    int dst=0;
    for (int src=0; src < numPairs; src++) {
      BasicBlockOperand bbop=Phi.getPred(s,src);
      if (bbop.block == source) {
        Phi.setValue(s,src,null);
        Phi.setPred(s,src,null);
      }
 else {
        if (src != dst) {
          Phi.setValue(s,dst,Phi.getClearValue(s,src));
          Phi.setPred(s,dst,Phi.getClearPred(s,src));
        }
        dst++;
      }
    }
    for (int i=dst; i < numPairs; i++) {
      Phi.setValue(s,i,null);
      Phi.setPred(s,i,null);
    }
  }
}

static void purgeBlockFromPHIs ( BasicBlock source , BasicBlock target ) { for ( Enumeration < Instruction > e = target . forwardRealInstrEnumerator ( ) ; e . hasMoreElements ( ) ; ) { Instruction s = e . nextElement ( ) ; if ( s . operator ( ) != PHI ) return ; int numPairs = Phi . getNumberOfPreds ( s ) ; int dst = 0 ; for ( int src = 0 ; src < numPairs ; src ++ ) { BasicBlockOperand bbop = Phi . getPred ( s , src ) ; if ( bbop . block == source ) { Phi . setValue ( s , src , null ) ; Phi . setPred ( s , src , null ) ; } else { if ( src != dst ) { Phi . setValue ( s , dst , Phi . getClearValue ( s , src ) ) ; Phi . setPred ( s , dst , Phi . getClearPred ( s , src ) ) ; } dst ++ ; } } for ( int i = dst ; i < numPairs ; i ++ ) { Phi . setValue ( s , i , null ) ; Phi . setPred ( s , i , null ) ; } } }
fix up any phi instructions in the given target block to reflect that the given source block is no longer a predecessor of target . the basic algorithm is to erase the phi operands related to the edge from source to target by sliding the other phi operands down as required .
