summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-09 23:29:37 +0000
committerChris Lattner <sabre@nondot.org>2007-01-09 23:29:37 +0000
commit8571caa99b0bdc7c71da9fd3c7f94f323617bd1b (patch)
tree6256b9038b6a3909b407d85682964f77187ed862 /llvm/lib/Transforms/IPO/GlobalOpt.cpp
parente3db84c6c2ad54956f423088b4b487e187f956c4 (diff)
downloadbcm5719-llvm-8571caa99b0bdc7c71da9fd3c7f94f323617bd1b.tar.gz
bcm5719-llvm-8571caa99b0bdc7c71da9fd3c7f94f323617bd1b.zip
Fix a bug in heap-sra that caused compilation failure of office-ispell.
llvm-svn: 33043
Diffstat (limited to 'llvm/lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index e17ded82d92..f25621eb78c 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1016,9 +1016,25 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI){
// loads, and all uses of those loads are simple. Rewrite them to use loads
// of the per-field globals instead.
while (!GV->use_empty()) {
- LoadInst *LI = cast<LoadInst>(GV->use_back());
- RewriteUsesOfLoadForHeapSRoA(LI, FieldGlobals);
- LI->eraseFromParent();
+ if (LoadInst *LI = dyn_cast<LoadInst>(GV->use_back())) {
+ RewriteUsesOfLoadForHeapSRoA(LI, FieldGlobals);
+ LI->eraseFromParent();
+ } else {
+ // Must be a store of null.
+ StoreInst *SI = cast<StoreInst>(GV->use_back());
+ assert(isa<Constant>(SI->getOperand(0)) &&
+ cast<Constant>(SI->getOperand(0))->isNullValue() &&
+ "Unexpected heap-sra user!");
+
+ // Insert a store of null into each global.
+ for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) {
+ Constant *Null =
+ Constant::getNullValue(FieldGlobals[i]->getType()->getElementType());
+ new StoreInst(Null, FieldGlobals[i], SI);
+ }
+ // Erase the original store.
+ SI->eraseFromParent();
+ }
}
// The old global is now dead, remove it.
OpenPOWER on IntegriCloud