[PATCH] D84873: AMDGPU: In determining load clobbering in AnnotateUniform, don't scan if there are too many blocks.

Changpeng Fang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 10:18:09 PDT 2020


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

The algorithm to find load clobbering in function is in the order of O^2.
The compilation becomes very slow if there are too many blocks ( ~3000).
To limit the compile time, we introduce a threshold (default 2500) of the 
number of basic blocks.


https://reviews.llvm.org/D84873

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
@@ -21,6 +21,7 @@
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InstVisitor.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -28,6 +29,10 @@
 
 using namespace llvm;
 
+static cl::opt<size_t> BasicBlockScanLimit("amdgpu-annotate-uniform-bb-limit",
+                    cl::Hidden, cl::init(2500),
+                    cl::desc("Max num BBs to scan in uniform annotation"));
+
 namespace {
 
 class AMDGPUAnnotateUniformValues : public FunctionPass,
@@ -105,6 +110,11 @@
   }
 
   DFS(Start, Checklist);
+
+  // To impove compilation, don't scan if there are too many BBS.
+  if (Checklist.size() > BasicBlockScanLimit)
+    return true;
+
   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: D84873.281649.patch
Type: text/x-patch
Size: 1149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200729/d29f6368/attachment.bin>


More information about the llvm-commits mailing list