[PATCH] D35105: [SjLj] Replace recursive block marking algorithm with iterative algorithm

Gerolf Hoflehner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 21:34:27 PDT 2017


Gerolf created this revision.

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


https://reviews.llvm.org/D35105

Files:
  lib/CodeGen/SjLjEHPrepare.cpp


Index: lib/CodeGen/SjLjEHPrepare.cpp
===================================================================
--- lib/CodeGen/SjLjEHPrepare.cpp
+++ lib/CodeGen/SjLjEHPrepare.cpp
@@ -125,8 +125,11 @@
   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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35105.105585.patch
Type: text/x-patch
Size: 574 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170707/fa190667/attachment.bin>


More information about the llvm-commits mailing list