teach reassociate to factor x+x+x -> x*3. While I'm at it,
[oota-llvm.git] / lib / VMCore / BasicBlock.cpp
index c609ef85ebd278142ad48c125eb8239125fc5815..16437bc130454d333166f9e99ef03cc6a7d3e260 100644 (file)
@@ -35,7 +35,7 @@ LLVMContext &BasicBlock::getContext() const {
 
 // Explicit instantiation of SymbolTableListTraits since some of the methods
 // are not in the public header file...
-template class SymbolTableListTraits<Instruction, BasicBlock>;
+template class llvm::SymbolTableListTraits<Instruction, BasicBlock>;
 
 
 BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent,
@@ -63,13 +63,15 @@ BasicBlock::~BasicBlock() {
   // hanging off the block, or an undefined use of the block (source code
   // expecting the address of a label to keep the block alive even though there
   // is no indirect branch).  Handle these cases by zapping the BlockAddress
-  // nodes, replacing them with BlockAddress(F, NULL).  There are no other
-  // possible uses at this point.
+  // nodes.  There are no other possible uses at this point.
   if (hasAddressTaken()) {
     assert(!use_empty() && "There should be at least one blockaddress!");
+    Constant *Replacement =
+      ConstantInt::get(llvm::Type::getInt32Ty(getContext()), 1);
     while (!use_empty()) {
       BlockAddress *BA = cast<BlockAddress>(use_back());
-      BA->replaceAllUsesWith(BlockAddress::get(BA->getFunction(), 0));
+      BA->replaceAllUsesWith(ConstantExpr::getIntToPtr(Replacement,
+                                                       BA->getType()));
       BA->destroyConstant();
     }
   }
@@ -260,7 +262,7 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
   assert(I != InstList.end() &&
          "Trying to get me to create degenerate basic block!");
 
-  BasicBlock *InsertBefore = next(Function::iterator(this))
+  BasicBlock *InsertBefore = llvm::next(Function::iterator(this))
                                .getNodePtrUnchecked();
   BasicBlock *New = BasicBlock::Create(getContext(), BBName,
                                        getParent(), InsertBefore);