LLVM  5.0.0
OrderedInstructions.h
Go to the documentation of this file.
1 //===- llvm/Transforms/Utils/OrderedInstructions.h -------------*- 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 an efficient way to check for dominance relation between 2
11 // instructions.
12 //
13 // This interface dispatches to appropriate dominance check given 2
14 // instructions, i.e. in case the instructions are in the same basic block,
15 // OrderedBasicBlock (with instruction numbering and caching) are used.
16 // Otherwise, dominator tree is used.
17 //
18 //===----------------------------------------------------------------------===//
19 
20 #ifndef LLVM_TRANSFORMS_UTILS_ORDEREDINSTRUCTIONS_H
21 #define LLVM_TRANSFORMS_UTILS_ORDEREDINSTRUCTIONS_H
22 
23 #include "llvm/ADT/DenseMap.h"
25 #include "llvm/IR/Dominators.h"
26 #include "llvm/IR/Operator.h"
27 
28 namespace llvm {
29 
31  /// Used to check dominance for instructions in same basic block.
33  OBBMap;
34 
35  /// The dominator tree of the parent function.
36  DominatorTree *DT;
37 
38 public:
39  /// Constructor.
41 
42  /// Return true if first instruction dominates the second.
43  bool dominates(const Instruction *, const Instruction *) const;
44 
45  /// Invalidate the OrderedBasicBlock cache when its basic block changes.
46  /// i.e. If an instruction is deleted or added to the basic block, the user
47  /// should call this function to invalidate the OrderedBasicBlock cache for
48  /// this basic block.
49  void invalidateBlock(const BasicBlock *BB) { OBBMap.erase(BB); }
50 };
51 
52 } // end namespace llvm
53 
54 #endif // LLVM_TRANSFORMS_UTILS_ORDEREDINSTRUCTIONS_H
bool dominates(const Instruction *, const Instruction *) const
Return true if first instruction dominates the second.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:134
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
void invalidateBlock(const BasicBlock *BB)
Invalidate the OrderedBasicBlock cache when its basic block changes.
OrderedInstructions(DominatorTree *DT)
Constructor.