Example #1
0
  /// Like ValueIsPHI but also check if the PHI has no source
  /// operands, i.e., it was just added.
  static SILPhiArgument *ValueIsNewPHI(SILValue Val, SILSSAUpdater *Updater) {
    SILPhiArgument *PHI = ValueIsPHI(Val, Updater);
    if (PHI) {
      auto *PhiBB = PHI->getParent();
      size_t PhiIdx = PHI->getIndex();

      // If all predecessor edges are 'not set' this is a new phi.
      for (auto *PredBB : PhiBB->getPredecessorBlocks()) {
        OperandValueArrayRef Edges =
            getEdgeValuesForTerminator(PredBB->getTerminator(), PhiBB);

        assert(PhiIdx < Edges.size() && "Not enough edges!");

        SILValue V = Edges[PhiIdx];
        // Check for the 'not set' sentinel.
        if (V != Updater->PHISentinel.get())
          return nullptr;
      }
      return PHI;
    }
    return nullptr;
  }
Example #2
0
 /// ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source
 /// operands, i.e., it was just added.
 static PHINode *ValueIsNewPHI(Value *Val, SSAUpdater *Updater) {
   PHINode *PHI = ValueIsPHI(Val, Updater);
   if (PHI && PHI->getNumIncomingValues() == 0)
     return PHI;
   return nullptr;
 }
 /// ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source
 /// operands, i.e., it was just added.
 static MachineInstr *ValueIsNewPHI(unsigned Val, MachineSSAUpdater *Updater) {
   MachineInstr *PHI = ValueIsPHI(Val, Updater);
   if (PHI && PHI->getNumOperands() <= 1)
     return PHI;
   return 0;
 }