[llvm-commits] CVS: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp

Chris Lattner sabre at nondot.org
Fri Dec 22 15:14:57 PST 2006



Changes in directory llvm/lib/Transforms/Scalar:

ScalarReplAggregates.cpp updated: 1.59 -> 1.60
---
Log message:

add a simple fast-path for dead allocas


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

 ScalarReplAggregates.cpp |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.59 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.60
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.59	Tue Dec 19 15:40:18 2006
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp	Fri Dec 22 17:14:42 2006
@@ -139,6 +139,13 @@
     AllocationInst *AI = WorkList.back();
     WorkList.pop_back();
     
+    // Handle dead allocas trivially.  These can be formed by SROA'ing arrays
+    // with unused elements.
+    if (AI->use_empty()) {
+      AI->eraseFromParent();
+      continue;
+    }
+    
     // If we can turn this aggregate value (potentially with casts) into a
     // simple scalar value that can be mem2reg'd into a register value.
     bool IsNotTrivial = false;
@@ -232,7 +239,7 @@
     }
 
     // Finally, delete the Alloca instruction
-    AI->getParent()->getInstList().erase(AI);
+    AI->eraseFromParent();
     NumReplaced++;
   }
 






More information about the llvm-commits mailing list