LLVM  3.7.0
LazyValueInfo.h
Go to the documentation of this file.
1 //===- LazyValueInfo.h - Value constraint 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 // This file defines the interface for lazy computation of value constraint
11 // information.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_ANALYSIS_LAZYVALUEINFO_H
16 #define LLVM_ANALYSIS_LAZYVALUEINFO_H
17 
18 #include "llvm/Pass.h"
19 
20 namespace llvm {
21  class AssumptionCache;
22  class Constant;
23  class DataLayout;
24  class DominatorTree;
25  class Instruction;
26  class TargetLibraryInfo;
27  class Value;
28 
29 /// This pass computes, caches, and vends lazy value constraint information.
30 class LazyValueInfo : public FunctionPass {
31  AssumptionCache *AC;
32  class TargetLibraryInfo *TLI;
33  DominatorTree *DT;
34  void *PImpl;
35  LazyValueInfo(const LazyValueInfo&) = delete;
36  void operator=(const LazyValueInfo&) = delete;
37 public:
38  static char ID;
39  LazyValueInfo() : FunctionPass(ID), PImpl(nullptr) {
41  }
42  ~LazyValueInfo() override { assert(!PImpl && "releaseMemory not called"); }
43 
44  /// This is used to return true/false/dunno results.
45  enum Tristate {
46  Unknown = -1, False = 0, True = 1
47  };
48 
49 
50  // Public query interface.
51 
52  /// Determine whether the specified value comparison with a constant is known
53  /// to be true or false on the specified CFG edge.
54  /// Pred is a CmpInst predicate.
55  Tristate getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
56  BasicBlock *FromBB, BasicBlock *ToBB,
57  Instruction *CxtI = nullptr);
58 
59  /// Determine whether the specified value comparison with a constant is known
60  /// to be true or false at the specified instruction
61  /// (from an assume intrinsic). Pred is a CmpInst predicate.
62  Tristate getPredicateAt(unsigned Pred, Value *V, Constant *C,
63  Instruction *CxtI);
64 
65  /// Determine whether the specified value is known to be a
66  /// constant at the end of the specified block. Return null if not.
67  Constant *getConstant(Value *V, BasicBlock *BB, Instruction *CxtI = nullptr);
68 
69  /// Determine whether the specified value is known to be a
70  /// constant on the specified edge. Return null if not.
72  Instruction *CxtI = nullptr);
73 
74  /// Inform the analysis cache that we have threaded an edge from
75  /// PredBB to OldSucc to be from PredBB to NewSucc instead.
76  void threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc, BasicBlock *NewSucc);
77 
78  /// Inform the analysis cache that we have erased a block.
79  void eraseBlock(BasicBlock *BB);
80 
81  // Implementation boilerplate.
82 
83  void getAnalysisUsage(AnalysisUsage &AU) const override;
84  void releaseMemory() override;
85  bool runOnFunction(Function &F) override;
86 };
87 
88 } // end namespace llvm
89 
90 #endif
91 
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A cache of .assume calls within a function.
F(f)
Constant * getConstant(Value *V, BasicBlock *BB, Instruction *CxtI=nullptr)
Determine whether the specified value is known to be a constant at the end of the specified block...
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:67
Constant * getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB, Instruction *CxtI=nullptr)
Determine whether the specified value is known to be a constant on the specified edge.
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
This is an important base class in LLVM.
Definition: Constant.h:41
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:294
Tristate
This is used to return true/false/dunno results.
Definition: LazyValueInfo.h:45
Tristate getPredicateOnEdge(unsigned Pred, Value *V, Constant *C, BasicBlock *FromBB, BasicBlock *ToBB, Instruction *CxtI=nullptr)
Determine whether the specified value comparison with a constant is known to be true or false on the ...
Tristate getPredicateAt(unsigned Pred, Value *V, Constant *C, Instruction *CxtI)
Determine whether the specified value comparison with a constant is known to be true or false at the ...
Provides information about what library functions are available for the current target.
void threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc, BasicBlock *NewSucc)
Inform the analysis cache that we have threaded an edge from PredBB to OldSucc to be from PredBB to N...
void eraseBlock(BasicBlock *BB)
Inform the analysis cache that we have erased a block.
This pass computes, caches, and vends lazy value constraint information.
Definition: LazyValueInfo.h:30
~LazyValueInfo() override
Definition: LazyValueInfo.h:42
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
LLVM Value Representation.
Definition: Value.h:69
void initializeLazyValueInfoPass(PassRegistry &)