Basic blocks typically have few predecessors. Use a SmallDenseMap to
authorChris Lattner <sabre@nondot.org>
Mon, 14 Oct 2013 16:05:55 +0000 (16:05 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 14 Oct 2013 16:05:55 +0000 (16:05 +0000)
avoid a heap allocation when this is the case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192602 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SSAUpdater.cpp

index fc85ef3207694c4cc666ca7a72058fc8fd1b94cb..30adbfac058f0d21a84084fa1c4e7a463f07eccc 100644 (file)
@@ -63,7 +63,7 @@ void SSAUpdater::AddAvailableValue(BasicBlock *BB, Value *V) {
 }
 
 static bool IsEquivalentPHI(PHINode *PHI,
-                            DenseMap<BasicBlock*, Value*> &ValueMapping) {
+                          SmallDenseMap<BasicBlock*, Value*, 8> &ValueMapping) {
   unsigned PHINumValues = PHI->getNumIncomingValues();
   if (PHINumValues != ValueMapping.size())
     return false;
@@ -136,8 +136,8 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
   // Otherwise, we do need a PHI: check to see if we already have one available
   // in this block that produces the right value.
   if (isa<PHINode>(BB->begin())) {
-    DenseMap<BasicBlock*, Value*> ValueMapping(PredValues.begin(),
-                                               PredValues.end());
+    SmallDenseMap<BasicBlock*, Value*, 8> ValueMapping(PredValues.begin(),
+                                                       PredValues.end());
     PHINode *SomePHI;
     for (BasicBlock::iterator It = BB->begin();
          (SomePHI = dyn_cast<PHINode>(It)); ++It) {