[PATCH] D98528: [AMDGPU] Use depth first iterator instead of recursive DFS. NFCI.

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 10:04:13 PST 2021


foad created this revision.
foad added reviewers: arsenm, rampitec.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
foad requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98528

Files:
  llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAnnotateUniformValues.cpp
@@ -14,6 +14,7 @@
 
 #include "AMDGPU.h"
 #include "Utils/AMDGPUBaseInfo.h"
+#include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
 #include "llvm/Analysis/LoopInfo.h"
@@ -75,12 +76,6 @@
   I->setMetadata("amdgpu.noclobber", MDNode::get(I->getContext(), {}));
 }
 
-static void DFS(BasicBlock *Root, SetVector<BasicBlock*> & Set) {
-  for (auto I : predecessors(Root))
-    if (Set.insert(I))
-      DFS(I, Set);
-}
-
 bool AMDGPUAnnotateUniformValues::isClobberedInFunction(LoadInst * Load) {
   // 1. get Loop for the Load->getparent();
   // 2. if it exists, collect all the BBs from the most outer
@@ -101,7 +96,7 @@
     Start = L->getHeader();
   }
 
-  DFS(Start, Checklist);
+  Checklist.insert(idf_begin(Start), idf_end(Start));
   for (auto &BB : Checklist) {
     BasicBlock::iterator StartIt = (!L && (BB == Load->getParent())) ?
       BasicBlock::iterator(Load) : BB->end();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98528.330288.patch
Type: text/x-patch
Size: 1210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210312/68bdbdda/attachment.bin>


More information about the llvm-commits mailing list