[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Sep 13 12:24:13 PDT 2006



Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.46 -> 1.47
---
Log message:

Implement the first half of Transforms/Inline/inline_cleanup.ll


---
Diffs of the changes:  (+9 -1)

 InlineFunction.cpp |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.46 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.47
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.46	Tue Jul 18 16:48:57 2006
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp	Wed Sep 13 14:23:57 2006
@@ -245,7 +245,14 @@
     BasicBlock::iterator InsertPoint = Caller->begin()->begin();
     for (BasicBlock::iterator I = FirstNewBlock->begin(),
            E = FirstNewBlock->end(); I != E; )
-      if (AllocaInst *AI = dyn_cast<AllocaInst>(I++))
+      if (AllocaInst *AI = dyn_cast<AllocaInst>(I++)) {
+        // If the alloca is now dead, remove it.  This often occurs due to code
+        // specialization.
+        if (AI->use_empty()) {
+          AI->eraseFromParent();
+          continue;
+        }
+        
         if (isa<Constant>(AI->getArraySize())) {
           // Scan for the block of allocas that we can move over, and move them
           // all at once.
@@ -260,6 +267,7 @@
                                                FirstNewBlock->getInstList(),
                                                AI, I);
         }
+      }
   }
 
   // If the inlined code contained dynamic alloca instructions, wrap the inlined






More information about the llvm-commits mailing list