[PATCH] D46671: Use iteration instead of recursion in CFIInserter

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 9 18:54:33 PDT 2018


sanjoy updated this revision to Diff 146051.
sanjoy added a comment.

- Use SmallVector::append


Repository:
  rL LLVM

https://reviews.llvm.org/D46671

Files:
  lib/CodeGen/CFIInstrInserter.cpp


Index: lib/CodeGen/CFIInstrInserter.cpp
===================================================================
--- lib/CodeGen/CFIInstrInserter.cpp
+++ lib/CodeGen/CFIInstrInserter.cpp
@@ -222,13 +222,20 @@
 }
 
 void CFIInstrInserter::updateSuccCFAInfo(MBBCFAInfo &MBBInfo) {
-  for (MachineBasicBlock *Succ : MBBInfo.MBB->successors()) {
+  SmallVector<MachineBasicBlock *, 4> Stack(MBBInfo.MBB->successors().begin(),
+                                            MBBInfo.MBB->successors().end());
+
+  while (!Stack.empty()) {
+    MachineBasicBlock *Succ = Stack.pop_back_val();
     MBBCFAInfo &SuccInfo = MBBVector[Succ->getNumber()];
-    if (SuccInfo.Processed) continue;
+    if (SuccInfo.Processed)
+      continue;
+
     SuccInfo.IncomingCFAOffset = MBBInfo.OutgoingCFAOffset;
     SuccInfo.IncomingCFARegister = MBBInfo.OutgoingCFARegister;
     calculateOutgoingCFAInfo(SuccInfo);
-    updateSuccCFAInfo(SuccInfo);
+    Stack.append(SuccInfo.MBB->successors().begin(),
+                 SuccInfo.MBB->successors().end());
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46671.146051.patch
Type: text/x-patch
Size: 1042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180510/5db1b8cd/attachment.bin>


More information about the llvm-commits mailing list