diff options
Diffstat (limited to 'lib/Transforms/Utils/SSAUpdater.cpp')
| -rw-r--r-- | lib/Transforms/Utils/SSAUpdater.cpp | 25 | 
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/Transforms/Utils/SSAUpdater.cpp b/lib/Transforms/Utils/SSAUpdater.cpp index 30adbfac058f0..3fcb789bd8425 100644 --- a/lib/Transforms/Utils/SSAUpdater.cpp +++ b/lib/Transforms/Utils/SSAUpdater.cpp @@ -11,17 +11,14 @@  //  //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "ssaupdater"  #include "llvm/Transforms/Utils/SSAUpdater.h"  #include "llvm/ADT/DenseMap.h"  #include "llvm/ADT/TinyPtrVector.h"  #include "llvm/Analysis/InstructionSimplify.h" +#include "llvm/IR/CFG.h"  #include "llvm/IR/Constants.h"  #include "llvm/IR/Instructions.h"  #include "llvm/IR/IntrinsicInst.h" -#include "llvm/Support/AlignOf.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/CFG.h"  #include "llvm/Support/Debug.h"  #include "llvm/Support/raw_ostream.h"  #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -30,20 +27,22 @@  using namespace llvm; +#define DEBUG_TYPE "ssaupdater" +  typedef DenseMap<BasicBlock*, Value*> AvailableValsTy;  static AvailableValsTy &getAvailableVals(void *AV) {    return *static_cast<AvailableValsTy*>(AV);  }  SSAUpdater::SSAUpdater(SmallVectorImpl<PHINode*> *NewPHI) -  : AV(0), ProtoType(0), ProtoName(), InsertedPHIs(NewPHI) {} +  : AV(nullptr), ProtoType(nullptr), ProtoName(), InsertedPHIs(NewPHI) {}  SSAUpdater::~SSAUpdater() {    delete static_cast<AvailableValsTy*>(AV);  }  void SSAUpdater::Initialize(Type *Ty, StringRef Name) { -  if (AV == 0) +  if (!AV)      AV = new AvailableValsTy();    else      getAvailableVals(AV).clear(); @@ -56,7 +55,7 @@ bool SSAUpdater::HasValueForBlock(BasicBlock *BB) const {  }  void SSAUpdater::AddAvailableValue(BasicBlock *BB, Value *V) { -  assert(ProtoType != 0 && "Need to initialize SSAUpdater"); +  assert(ProtoType && "Need to initialize SSAUpdater");    assert(ProtoType == V->getType() &&           "All rewritten values must have the same type");    getAvailableVals(AV)[BB] = V; @@ -92,7 +91,7 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {    // Otherwise, we have the hard case.  Get the live-in values for each    // predecessor.    SmallVector<std::pair<BasicBlock*, Value*>, 8> PredValues; -  Value *SingularValue = 0; +  Value *SingularValue = nullptr;    // We can get our predecessor info by walking the pred_iterator list, but it    // is relatively slow.  If we already have PHI nodes in this block, walk one @@ -107,7 +106,7 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {        if (i == 0)          SingularValue = PredVal;        else if (PredVal != SingularValue) -        SingularValue = 0; +        SingularValue = nullptr;      }    } else {      bool isFirstPred = true; @@ -121,7 +120,7 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {          SingularValue = PredVal;          isFirstPred = false;        } else if (PredVal != SingularValue) -        SingularValue = 0; +        SingularValue = nullptr;      }    } @@ -130,7 +129,7 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {      return UndefValue::get(ProtoType);    // Otherwise, if all the merged values are the same, just use it. -  if (SingularValue != 0) +  if (SingularValue)      return SingularValue;    // Otherwise, we do need a PHI: check to see if we already have one available @@ -293,7 +292,7 @@ public:      PHINode *PHI = ValueIsPHI(Val, Updater);      if (PHI && PHI->getNumIncomingValues() == 0)        return PHI; -    return 0; +    return nullptr;    }    /// GetPHIValue - For the specified PHI instruction, return the value @@ -403,7 +402,7 @@ run(const SmallVectorImpl<Instruction*> &Insts) const {      // the order of these instructions in the block.  If the first use in the      // block is a load, then it uses the live in value.  The last store defines      // the live out value.  We handle this by doing a linear scan of the block. -    Value *StoredValue = 0; +    Value *StoredValue = nullptr;      for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E; ++II) {        if (LoadInst *L = dyn_cast<LoadInst>(II)) {          // If this is a load from an unrelated pointer, ignore it.  | 
