[llvm] r307860 - [SjLj] Replace recursive block marking algorithm with iterative algorithm

Gerolf Hoflehner via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 16:05:15 PDT 2017


Author: ghoflehner
Date: Wed Jul 12 16:05:15 2017
New Revision: 307860

URL: http://llvm.org/viewvc/llvm-project?rev=307860&view=rev
Log:
[SjLj] Replace recursive block marking algorithm with iterative algorithm

Summary:
Some programs run into a stack overflow issue. This change avoids this
problem by replacing the recursive algorithm with the iterative version.

Reviewers: MatzeB, t.p.northover, dblaikie

Reviewed By: MatzeB

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35105

Modified:
    llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp

Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=307860&r1=307859&r2=307860&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Wed Jul 12 16:05:15 2017
@@ -125,8 +125,11 @@ static void MarkBlocksLiveIn(BasicBlock
   if (!LiveBBs.insert(BB).second)
     return; // already been here.
 
-  for (BasicBlock *PredBB : predecessors(BB))
-    MarkBlocksLiveIn(PredBB, LiveBBs);
+  df_iterator_default_set<BasicBlock*> Visited;
+
+  for (BasicBlock *B : inverse_depth_first_ext(BB, Visited))
+    LiveBBs.insert(B);
+
 }
 
 /// substituteLPadValues - Substitute the values returned by the landingpad




More information about the llvm-commits mailing list