Fix a bug in non-local memdep that was causing an infinite loop on 175.vpr.

llvm-svn: 40495
This commit is contained in:
Owen Anderson 2007-07-25 21:26:36 +00:00
parent 7bf26ee444
commit 9b796348bd
2 changed files with 27 additions and 3 deletions

View File

@ -103,7 +103,8 @@ Instruction* MemoryDependenceAnalysis::getCallSiteDependency(CallSite C, Instruc
bool MemoryDependenceAnalysis::nonLocalHelper(Instruction* query, bool MemoryDependenceAnalysis::nonLocalHelper(Instruction* query,
BasicBlock* block, BasicBlock* block,
DenseMap<BasicBlock*, Value*>& resp) { DenseMap<BasicBlock*, Value*>& resp,
SmallPtrSet<BasicBlock*, 4>& visited) {
if (resp.count(block)) if (resp.count(block))
return resp[block] != None; return resp[block] != None;
@ -113,10 +114,15 @@ bool MemoryDependenceAnalysis::nonLocalHelper(Instruction* query,
return true; return true;
} }
visited.insert(block);
bool inserted = false; bool inserted = false;
for (pred_iterator PI = pred_begin(block), PE = pred_end(block); for (pred_iterator PI = pred_begin(block), PE = pred_end(block);
PI != PE; ++PI) PI != PE; ++PI)
inserted |= nonLocalHelper(query, *PI, resp); if (!visited.count(*PI))
inserted |= nonLocalHelper(query, *PI, resp, visited);
visited.erase(block);
if (!inserted) if (!inserted)
resp.insert(std::make_pair(block, None)); resp.insert(std::make_pair(block, None));
@ -133,11 +139,14 @@ bool MemoryDependenceAnalysis::getNonLocalDependency(Instruction* query,
} }
bool inserted = false; bool inserted = false;
SmallPtrSet<BasicBlock*, 4> visited;
visited.insert(query->getParent());
BasicBlock* parent = query->getParent(); BasicBlock* parent = query->getParent();
for (pred_iterator PI = pred_begin(parent), PE = pred_end(parent); for (pred_iterator PI = pred_begin(parent), PE = pred_end(parent);
PI != PE; ++PI) { PI != PE; ++PI) {
inserted |= nonLocalHelper(query, *PI, resp); if (!visited.count(*PI))
inserted |= nonLocalHelper(query, *PI, resp, visited);
} }
if (!inserted) if (!inserted)

View File

@ -0,0 +1,15 @@
; RUN: llvm-as < %s | opt -gvn | llvm-dis
%struct.s_segment_inf = type { float, i32, i16, i16, float, float, i32, float, float }
define void @print_arch(i8* %arch_file, i32 %route_type, i64 %det_routing_arch.0.0, i64 %det_routing_arch.0.1, i64 %det_routing_arch.0.2, i64 %det_routing_arch.0.3, i64 %det_routing_arch.0.4, %struct.s_segment_inf* %segment_inf, i64 %timing_inf.0.0, i64 %timing_inf.0.1, i64 %timing_inf.0.2, i64 %timing_inf.0.3, i64 %timing_inf.0.4, i32 %timing_inf.1) {
entry:
br i1 false, label %bb278, label %bb344
bb278: ; preds = %bb278, %entry
br i1 false, label %bb278, label %bb344
bb344: ; preds = %bb278, %entry
%tmp38758 = load i16* null, align 2 ; <i16> [#uses=0]
ret void
}