Add a new llvm::SmallVector template, which is similar to the vector class, but
[oota-llvm.git] / lib / VMCore / BasicBlock.cpp
index c93f5584d27402be6da0d45f17817cc29131a209..13907c10389817a9dedf0123507a9a2cf093aedf 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/Type.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/LeakDetector.h"
+#include "llvm/Support/Visibility.h"
 #include "SymbolTableListTraitsImpl.h"
 #include <algorithm>
 using namespace llvm;
@@ -24,7 +25,7 @@ using namespace llvm;
 namespace {
   /// DummyInst - An instance of this class is used to mark the end of the
   /// instruction list.  This is not a real instruction.
-  struct DummyInst : public Instruction {
+  struct VISIBILITY_HIDDEN DummyInst : public Instruction {
     DummyInst() : Instruction(Type::VoidTy, OtherOpsEnd, 0, 0) {
       // This should not be garbage monitored.
       LeakDetector::removeGarbageObject(this);
@@ -123,7 +124,7 @@ const TerminatorInst *const BasicBlock::getTerminator() const {
 
 Instruction* BasicBlock::getFirstNonPHI()
 {
-    BasicBlock::iterator i = begin(), e = end();
+    BasicBlock::iterator i = begin();
     // All valid basic blocks should have a terminator,
     // which is not a PHINode. If we have invalid basic
     // block we'll get assert when dereferencing past-the-end
@@ -213,7 +214,8 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
       PN->removeIncomingValue(Pred, false);
       // If all incoming values to the Phi are the same, we can replace the Phi
       // with that value.
-      if (Value *PNV = PN->hasConstantValue()) {
+      Value* PNV = 0;
+      if (!DontDeleteUselessPHIs && (PNV = PN->hasConstantValue())) {
         PN->replaceAllUsesWith(PNV);
         PN->eraseFromParent();
       }