LLVM  4.0.0
DivergenceAnalysis.h
Go to the documentation of this file.
1 //===- llvm/Analysis/DivergenceAnalysis.h - Divergence Analysis -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // The divergence analysis is an LLVM pass which can be used to find out
11 // if a branch instruction in a GPU program is divergent or not. It can help
12 // branch optimizations such as jump threading and loop unswitching to make
13 // better decisions.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #include "llvm/ADT/DenseSet.h"
18 #include "llvm/IR/Function.h"
19 #include "llvm/Pass.h"
20 
21 namespace llvm {
22 class Value;
24 public:
25  static char ID;
26 
29  }
30 
31  void getAnalysisUsage(AnalysisUsage &AU) const override;
32 
33  bool runOnFunction(Function &F) override;
34 
35  // Print all divergent branches in the function.
36  void print(raw_ostream &OS, const Module *) const override;
37 
38  // Returns true if V is divergent.
39  bool isDivergent(const Value *V) const { return DivergentValues.count(V); }
40 
41  // Returns true if V is uniform/non-divergent.
42  bool isUniform(const Value *V) const { return !isDivergent(V); }
43 
44 private:
45  // Stores all divergent values.
46  DenseSet<const Value *> DivergentValues;
47 };
48 } // End llvm namespace
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
Implements a dense probed hash-table based set.
Definition: DenseSet.h:202
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
#define F(x, y, z)
Definition: MD5.cpp:51
void initializeDivergenceAnalysisPass(PassRegistry &)
void print(raw_ostream &OS, const Module *) const override
print - Print out the internal state of the pass.
Represent the analysis usage information of a pass.
bool isDivergent(const Value *V) const
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
bool isUniform(const Value *V) const
static char ID
end namespace anonymous
LLVM Value Representation.
Definition: Value.h:71
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44