mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
Fix assertion in LICM doFinalization()
The doFinalization method checks that the LoopToAliasSetMap is empty. LICM populates that map as it runs through the loop nest, deleting the entries for child loops as it goes. However, if a child loop is deleted by another pass (e.g. unrolling) then the loop will never be deleted from the map because LICM walks the loop nest to find entries it can delete. The fix is to delete the loop from the map and free the alias set when the loop is deleted from the loop nest. Differential Revision: http://reviews.llvm.org/D5305 llvm-svn: 218387
This commit is contained in:
parent
3559e5b2b3
commit
1c44b9f4ef
@ -82,6 +82,11 @@ public:
|
|||||||
/// deleteAnalysisValue - Delete analysis info associated with value V.
|
/// deleteAnalysisValue - Delete analysis info associated with value V.
|
||||||
virtual void deleteAnalysisValue(Value *V, Loop *L) {}
|
virtual void deleteAnalysisValue(Value *V, Loop *L) {}
|
||||||
|
|
||||||
|
/// Delete analysis info associated with Loop L.
|
||||||
|
/// Called to notify a Pass that a loop has been deleted and any
|
||||||
|
/// associated analysis values can be deleted.
|
||||||
|
virtual void deleteAnalysisLoop(Loop *L) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// skipOptnoneFunction - Containing function has Attribute::OptimizeNone
|
/// skipOptnoneFunction - Containing function has Attribute::OptimizeNone
|
||||||
/// and most transformation passes should skip it.
|
/// and most transformation passes should skip it.
|
||||||
@ -152,6 +157,10 @@ public:
|
|||||||
/// that implement simple analysis interface.
|
/// that implement simple analysis interface.
|
||||||
void deleteSimpleAnalysisValue(Value *V, Loop *L);
|
void deleteSimpleAnalysisValue(Value *V, Loop *L);
|
||||||
|
|
||||||
|
/// Invoke deleteAnalysisLoop hook for all passes that implement simple
|
||||||
|
/// analysis interface.
|
||||||
|
void deleteSimpleAnalysisLoop(Loop *L);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<Loop *> LQ;
|
std::deque<Loop *> LQ;
|
||||||
bool skipThisLoop;
|
bool skipThisLoop;
|
||||||
|
@ -76,6 +76,9 @@ void LPPassManager::deleteLoopFromQueue(Loop *L) {
|
|||||||
|
|
||||||
LI->updateUnloop(L);
|
LI->updateUnloop(L);
|
||||||
|
|
||||||
|
// Notify passes that the loop is being deleted.
|
||||||
|
deleteSimpleAnalysisLoop(L);
|
||||||
|
|
||||||
// If L is current loop then skip rest of the passes and let
|
// If L is current loop then skip rest of the passes and let
|
||||||
// runOnFunction remove L from LQ. Otherwise, remove L from LQ now
|
// runOnFunction remove L from LQ. Otherwise, remove L from LQ now
|
||||||
// and continue applying other passes on CurrentLoop.
|
// and continue applying other passes on CurrentLoop.
|
||||||
@ -164,6 +167,14 @@ void LPPassManager::deleteSimpleAnalysisValue(Value *V, Loop *L) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Invoke deleteAnalysisLoop hook for all passes.
|
||||||
|
void LPPassManager::deleteSimpleAnalysisLoop(Loop *L) {
|
||||||
|
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
|
||||||
|
LoopPass *LP = getContainedPass(Index);
|
||||||
|
LP->deleteAnalysisLoop(L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Recurse through all subloops and all loops into LQ.
|
// Recurse through all subloops and all loops into LQ.
|
||||||
static void addLoopIntoQueue(Loop *L, std::deque<Loop *> &LQ) {
|
static void addLoopIntoQueue(Loop *L, std::deque<Loop *> &LQ) {
|
||||||
|
@ -130,6 +130,9 @@ namespace {
|
|||||||
/// set.
|
/// set.
|
||||||
void deleteAnalysisValue(Value *V, Loop *L) override;
|
void deleteAnalysisValue(Value *V, Loop *L) override;
|
||||||
|
|
||||||
|
/// Simple Analysis hook. Delete loop L from alias set map.
|
||||||
|
void deleteAnalysisLoop(Loop *L) override;
|
||||||
|
|
||||||
/// SinkRegion - Walk the specified region of the CFG (defined by all blocks
|
/// SinkRegion - Walk the specified region of the CFG (defined by all blocks
|
||||||
/// dominated by the specified block, and that are in the current loop) in
|
/// dominated by the specified block, and that are in the current loop) in
|
||||||
/// reverse depth first order w.r.t the DominatorTree. This allows us to
|
/// reverse depth first order w.r.t the DominatorTree. This allows us to
|
||||||
@ -943,3 +946,13 @@ void LICM::deleteAnalysisValue(Value *V, Loop *L) {
|
|||||||
|
|
||||||
AST->deleteValue(V);
|
AST->deleteValue(V);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Simple Analysis hook. Delete value L from alias set map.
|
||||||
|
void LICM::deleteAnalysisLoop(Loop *L) {
|
||||||
|
AliasSetTracker *AST = LoopToAliasSetMap.lookup(L);
|
||||||
|
if (!AST)
|
||||||
|
return;
|
||||||
|
|
||||||
|
delete AST;
|
||||||
|
LoopToAliasSetMap.erase(L);
|
||||||
|
}
|
||||||
|
30
test/Transforms/LICM/2014-09-10-doFinalizationAssert.ll
Normal file
30
test/Transforms/LICM/2014-09-10-doFinalizationAssert.ll
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
; RUN: opt < %s -scalar-evolution -licm -loop-unroll -disable-output
|
||||||
|
; Test triggered an assertion in doFinalization() because loop unroll was deleting
|
||||||
|
; the inner loop which caused the loop to not get removed from the
|
||||||
|
; LoopToAliasSetMap.
|
||||||
|
; Test case taken from test/Transforms/LoopUnroll/unloop.ll.
|
||||||
|
|
||||||
|
declare i1 @check() nounwind
|
||||||
|
define void @skiplevelexit() nounwind {
|
||||||
|
entry:
|
||||||
|
br label %outer
|
||||||
|
|
||||||
|
outer:
|
||||||
|
br label %inner
|
||||||
|
|
||||||
|
inner:
|
||||||
|
%iv = phi i32 [ 0, %outer ], [ %inc, %tail ]
|
||||||
|
%inc = add i32 %iv, 1
|
||||||
|
call zeroext i1 @check()
|
||||||
|
br i1 true, label %outer.backedge, label %tail
|
||||||
|
|
||||||
|
tail:
|
||||||
|
br i1 false, label %inner, label %exit
|
||||||
|
|
||||||
|
outer.backedge:
|
||||||
|
br label %outer
|
||||||
|
|
||||||
|
exit:
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user