From eaa243039b6a83f8915f4f96ced58fabb520c851 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 27 Jul 2004 07:38:32 +0000 Subject: [PATCH] Fix hoisting of void typed values, e.g. calls git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15263 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LICM.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 8bdde10b647..792a672f04b 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/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 Allocas; - Allocas.push_back(AI); - PromoteMemToReg(Allocas, *DT, *DF, AA->getTargetData()); + if (AI) { + std::vector Allocas; + Allocas.push_back(AI); + PromoteMemToReg(Allocas, *DT, *DF, AA->getTargetData()); + } } } -- 2.34.1