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

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 9 18:36:52 PDT 2018


dberris added inline comments.


================
Comment at: lib/CodeGen/CFIInstrInserter.cpp:225-228
+  SmallVector<MachineBasicBlock *, 4> Stack(MBBInfo.MBB->successors().begin(),
+                                            MBBInfo.MBB->successors().end());
+
+  while (!Stack.empty()) {
----------------
Does this change the order of iteration here? It looks like because you're using a stack and going from the top of the stack, it's slightly different from the BFS nature of the recursion, no?

Some questions: does it matter, and if it does, maybe use a queue?


================
Comment at: lib/CodeGen/CFIInstrInserter.cpp:237
     calculateOutgoingCFAInfo(SuccInfo);
-    updateSuccCFAInfo(SuccInfo);
+    llvm::copy(SuccInfo.MBB->successors(), std::back_inserter(Stack));
   }
----------------
Consider using `Stack.append(...)` instead, to reduce the requirement for incrementally growing the stack?


Repository:
  rL LLVM

https://reviews.llvm.org/D46671





More information about the llvm-commits mailing list