From 575ec806e0d6e10eaf1bbe4163379d51565f7fe4 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 25 Mar 2009 23:57:48 +0000 Subject: [PATCH] Before deleting a basic block, give other loop passes a chance cleanup analysis values, related to the instructions in the basic block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67719 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/LoopPass.cpp | 7 ++++ lib/Transforms/Scalar/LoopIndexSplit.cpp | 2 +- .../LICM/2009-03-25-AliasSetTracker.ll | 39 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/LICM/2009-03-25-AliasSetTracker.ll diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp index c4ff9889446..08c25f4ceae 100644 --- a/lib/Analysis/LoopPass.cpp +++ b/lib/Analysis/LoopPass.cpp @@ -152,6 +152,13 @@ void LPPassManager::cloneBasicBlockSimpleAnalysis(BasicBlock *From, /// deleteSimpleAnalysisValue - Invoke deleteAnalysisValue hook for all passes. void LPPassManager::deleteSimpleAnalysisValue(Value *V, Loop *L) { + if (BasicBlock *BB = dyn_cast(V)) { + for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE; + ++BI) { + Instruction &I = *BI; + deleteSimpleAnalysisValue(&I, L); + } + } for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { Pass *P = getContainedPass(Index); LoopPass *LP = dynamic_cast(P); diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index e93d448cc1b..98e5cc15d6c 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -673,6 +673,7 @@ void LoopIndexSplit::removeBlocks(BasicBlock *DeadBB, Loop *LP, while (!WorkList.empty()) { BasicBlock *BB = WorkList.back(); WorkList.pop_back(); + LPM->deleteSimpleAnalysisValue(BB, LP); for(BasicBlock::iterator BBI = BB->begin(), BBE = BB->end(); BBI != BBE; ) { Instruction *I = BBI; @@ -680,7 +681,6 @@ void LoopIndexSplit::removeBlocks(BasicBlock *DeadBB, Loop *LP, I->replaceAllUsesWith(UndefValue::get(I->getType())); I->eraseFromParent(); } - LPM->deleteSimpleAnalysisValue(BB, LP); DT->eraseNode(BB); DF->removeBlock(BB); LI->removeBlock(BB); diff --git a/test/Transforms/LICM/2009-03-25-AliasSetTracker.ll b/test/Transforms/LICM/2009-03-25-AliasSetTracker.ll new file mode 100644 index 00000000000..c3c9a810c52 --- /dev/null +++ b/test/Transforms/LICM/2009-03-25-AliasSetTracker.ll @@ -0,0 +1,39 @@ + +; RUN: llvm-as < %s | opt -licm -loop-index-split -instcombine -disable-output + + %struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i32, i32, [40 x i8] } + %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 } +@"\01LC81" = external constant [4 x i8] ; <[4 x i8]*> [#uses=1] + +define fastcc void @hex_dump_internal(i8* %avcl, %struct.FILE* %f, i32 %level, i8* nocapture %buf, i32 %size) nounwind { +entry: + br i1 false, label %bb4, label %return + +bb4: ; preds = %bb30, %entry + br label %bb6 + +bb6: ; preds = %bb15, %bb4 + %j.0.reg2mem.0 = phi i32 [ %2, %bb15 ], [ 0, %bb4 ] ; [#uses=2] + %0 = icmp slt i32 %j.0.reg2mem.0, 0 ; [#uses=1] + br i1 %0, label %bb7, label %bb13 + +bb7: ; preds = %bb6 + br label %bb15 + +bb13: ; preds = %bb6 + %1 = tail call i32 @fwrite(i8* getelementptr ([4 x i8]* @"\01LC81", i32 0, i32 0), i32 1, i32 3, i8* null) nounwind ; [#uses=0] + br label %bb15 + +bb15: ; preds = %bb13, %bb7 + %2 = add i32 %j.0.reg2mem.0, 1 ; [#uses=2] + %3 = icmp sgt i32 %2, 15 ; [#uses=1] + br i1 %3, label %bb30, label %bb6 + +bb30: ; preds = %bb15 + br i1 false, label %bb4, label %return + +return: ; preds = %bb30, %entry + ret void +} + +declare i32 @fwrite(i8* nocapture, i32, i32, i8* nocapture) nounwind