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 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();