diff options
author | Chris Lattner <sabre@nondot.org> | 2006-12-22 23:14:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-12-22 23:14:42 +0000 |
commit | f171af97d50df7ebd7661756e89eef2295014e81 (patch) | |
tree | c446ec566d0f706feaff374223abf02090b9c0b8 /llvm/lib | |
parent | cdd9807cbaf23bdb8fc3a8fa93f4e7eea4c30a69 (diff) | |
download | bcm5719-llvm-f171af97d50df7ebd7661756e89eef2295014e81.tar.gz bcm5719-llvm-f171af97d50df7ebd7661756e89eef2295014e81.zip |
add a simple fast-path for dead allocas
llvm-svn: 32750
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 160128eba1d..a92592b8166 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -139,6 +139,13 @@ bool SROA::performScalarRepl(Function &F) { 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 @@ bool SROA::performScalarRepl(Function &F) { } // Finally, delete the Alloca instruction - AI->getParent()->getInstList().erase(AI); + AI->eraseFromParent(); NumReplaced++; } |