about summary refs log tree commit diff
path: root/llvm_mode/MarkNodes.cc
diff options
context:
space:
mode:
Diffstat (limited to 'llvm_mode/MarkNodes.cc')
-rw-r--r--llvm_mode/MarkNodes.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm_mode/MarkNodes.cc b/llvm_mode/MarkNodes.cc
index 7b22bac0..b8587826 100644
--- a/llvm_mode/MarkNodes.cc
+++ b/llvm_mode/MarkNodes.cc
@@ -376,10 +376,10 @@ void MakeUniq(uint32_t now) {
 
 }
 
-void MarkSubGraph(uint32_t ss, uint32_t tt) {
+bool MarkSubGraph(uint32_t ss, uint32_t tt) {
 
   TopologicalSort(ss, tt);
-  if (TopoOrder.empty()) return;
+  if (TopoOrder.empty()) return false;
 
   for (uint32_t i : TopoOrder) {
 
@@ -393,6 +393,11 @@ void MarkSubGraph(uint32_t ss, uint32_t tt) {
     MakeUniq(TopoOrder[i]);
 
   }
+  
+   // Check if there is an empty path.
+  if (NextMarked[tt].count(TopoOrder[0]) > 0)
+    return true;
+  return false;
 
 }
 
@@ -417,13 +422,19 @@ void MarkVertice() {
 
   timeStamp = 0;
   uint32_t t = 0;
+  bool emptyPathExists = true;
 
   while (s != t) {
 
-    MarkSubGraph(DominatorTree::idom[t], t);
+    emptyPathExists &= MarkSubGraph(DominatorTree::idom[t], t);
     t = DominatorTree::idom[t];
 
   }
+  
+  if (emptyPathExists) {
+    // Mark all exit blocks to catch the empty path.
+    Marked.insert(t_Pred[0].begin(), t_Pred[0].end());
+  }
 
 }