From c955d212a8c060d7082fe975fd65fcbc9263853a Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 27 May 2011 18:04:04 +0000 Subject: Oops, wasn't intending to commit this. Partial revert of r132194. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132195 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LICM.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/Transforms/Scalar/LICM.cpp') diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 935cd5d1ee..d42d4ff837 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -372,11 +372,7 @@ bool LICM::canSinkOrHoistInst(Instruction &I) { return !pointerInvalidatedByLoop(LI->getOperand(0), Size, LI->getMetadata(LLVMContext::MD_tbaa)); } else if (CallInst *CI = dyn_cast(&I)) { - // Don't sink or hoist dbg info; it's legal, but not useful. - if (isa(I)) - return false; - - // Handle simple cases by querying alias analysis. + // Handle obvious cases efficiently. AliasAnalysis::ModRefBehavior Behavior = AA->getModRefBehavior(CI); if (Behavior == AliasAnalysis::DoesNotAccessMemory) return true; @@ -526,7 +522,14 @@ void LICM::sink(Instruction &I) { SSA.AddAvailableValue(ExitBlock, New); } - assert(NumInserted && "We shouldn't see dead instructions here!"); + // If the instruction doesn't dominate any exit blocks, it must be dead. + if (NumInserted == 0) { + CurAST->deleteValue(&I); + if (!I.use_empty()) + I.replaceAllUsesWith(UndefValue::get(I.getType())); + I.eraseFromParent(); + return; + } // Next, rewrite uses of the instruction, inserting PHI nodes as needed. for (Value::use_iterator UI = I.use_begin(), UE = I.use_end(); UI != UE; ) { -- cgit v1.2.3