From 3b5ab8f9039635fda547290fda398c1cd350423a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 8 Mar 2014 17:02:38 -0800 Subject: avoid infinite loops in AllocaManager::computeInterBlockLiveness --- lib/Target/JSBackend/AllocaManager.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/Target/JSBackend/AllocaManager.cpp b/lib/Target/JSBackend/AllocaManager.cpp index 4673a34644..b49e6c4de1 100644 --- a/lib/Target/JSBackend/AllocaManager.cpp +++ b/lib/Target/JSBackend/AllocaManager.cpp @@ -249,11 +249,15 @@ void AllocaManager::computeInterBlockLiveness() { // If it contains new live blocks, prepare to propagate them. if (Temp.test(BLI.LiveIn)) { BLI.LiveIn |= Temp; + BitVector LiveOut = BLI.LiveOut; BLI.LiveOut |= Temp; BLI.LiveOut.reset(BLI.End); - for (succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB); - SI != SE; ++SI) { - InterBlockWorklist.insert(*SI); + // If we actually added to live-out, re-process them + if (BLI.LiveOut.test(LiveOut)) { + for (succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB); + SI != SE; ++SI) { + InterBlockWorklist.insert(*SI); + } } } Temp.reset(); @@ -268,11 +272,15 @@ void AllocaManager::computeInterBlockLiveness() { if (Temp.test(BLI.LiveOut)) { // TODO: As above, what are the semantics of a standalone lifetime end? BLI.LiveOut |= Temp; + BitVector LiveIn = BLI.LiveIn; BLI.LiveIn |= Temp; BLI.LiveIn.reset(BLI.Start); - for (const_pred_iterator PI = pred_begin(BB), PE = pred_end(BB); - PI != PE; ++PI) { - InterBlockWorklist.insert(*PI); + // If we actually added to live-in, re-process them + if (BLI.LiveIn.test(LiveIn)) { + for (const_pred_iterator PI = pred_begin(BB), PE = pred_end(BB); + PI != PE; ++PI) { + InterBlockWorklist.insert(*PI); + } } } Temp.reset(); @@ -453,7 +461,6 @@ AllocaManager::AllocaManager() { void AllocaManager::analyze(const Function &Func, const DataLayout &Layout, bool PerformColoring) { NamedRegionTimer Timer("AllocaManager", TimePassesIsEnabled); - assert(Allocas.empty()); assert(AllocasByIndex.empty()); assert(AllocaCompatibility.empty()); -- cgit v1.2.3-18-g5258