summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LICM.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-27 07:38:32 +0000
committerChris Lattner <sabre@nondot.org>2004-07-27 07:38:32 +0000
commit50eb771d37ec6229c1013d28f871589c504d9ad4 (patch)
tree2bd396d09f50452c757b918701a4972b0c67bd6a /llvm/lib/Transforms/Scalar/LICM.cpp
parent89c0c0ae3ff7e4592598c8cc40e2ba6bebfe112e (diff)
downloadbcm5719-llvm-50eb771d37ec6229c1013d28f871589c504d9ad4.tar.gz
bcm5719-llvm-50eb771d37ec6229c1013d28f871589c504d9ad4.zip
Fix hoisting of void typed values, e.g. calls
llvm-svn: 15263
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LICM.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 8bdde10b647..792a672f04b 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -462,9 +462,12 @@ void LICM::sink(Instruction &I) {
// the value into a stack object to get it to do this.
// Firstly, we create a stack object to hold the value...
- AllocaInst *AI = new AllocaInst(I.getType(), 0, I.getName(),
- I.getParent()->getParent()->front().begin());
+ AllocaInst *AI = 0;
+ if (I.getType() != Type::VoidTy)
+ AI = new AllocaInst(I.getType(), 0, I.getName(),
+ I.getParent()->getParent()->front().begin());
+
// Secondly, insert load instructions for each use of the instruction
// outside of the loop.
while (!I.use_empty()) {
@@ -522,12 +525,13 @@ void LICM::sink(Instruction &I) {
New = &I;
} else {
New = I.clone();
- New->setName(I.getName()+".le");
+ if (!I.getName().empty())
+ New->setName(I.getName()+".le");
ExitBlock->getInstList().insert(InsertPt, New);
}
// Now that we have inserted the instruction, store it into the alloca
- new StoreInst(New, AI, InsertPt);
+ if (AI) new StoreInst(New, AI, InsertPt);
}
}
}
@@ -539,9 +543,11 @@ void LICM::sink(Instruction &I) {
}
// Finally, promote the fine value to SSA form.
- std::vector<AllocaInst*> Allocas;
- Allocas.push_back(AI);
- PromoteMemToReg(Allocas, *DT, *DF, AA->getTargetData());
+ if (AI) {
+ std::vector<AllocaInst*> Allocas;
+ Allocas.push_back(AI);
+ PromoteMemToReg(Allocas, *DT, *DF, AA->getTargetData());
+ }
}
}
OpenPOWER on IntegriCloud