LLVM: lib/Analysis/InstructionPrecedenceTracking.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
24
25using namespace llvm;
26
27#ifndef NDEBUG
29 "ipt-expensive-asserts",
30 cl::desc("Perform expensive assert validation on every query to Instruction"
31 " Precedence Tracking"),
33#endif
34
37#ifndef NDEBUG
38
39
41 validateAll();
42 else
43 validate(BB);
44#endif
45
46 auto [It, Inserted] = FirstSpecialInsts.try_emplace(BB);
47 if (Inserted) {
48 for (const auto &I : *BB) {
50 It->second = &I;
51 break;
52 }
53 }
54 }
55 return It->second;
56}
57
62
67 return MaybeFirstSpecial && MaybeFirstSpecial->comesBefore(Insn);
68}
69
70#ifndef NDEBUG
71void InstructionPrecedenceTracking::validate(const BasicBlock *BB) const {
72 auto It = FirstSpecialInsts.find(BB);
73
74 if (It == FirstSpecialInsts.end())
75 return;
76
79 assert(It->second == &Insn &&
80 "Cached first special instruction is wrong!");
81 return;
82 }
83
84 assert(It->second == nullptr &&
85 "Block is marked as having special instructions but in fact it has "
86 "none!");
87}
88
89void InstructionPrecedenceTracking::validateAll() const {
90
91 for (const auto &It : FirstSpecialInsts)
92 validate(It.first);
93}
94#endif
95
99 FirstSpecialInsts.erase(BB);
100}
101
104 assert(BB && "must be called before instruction is actually removed");
105 auto It = FirstSpecialInsts.find(BB);
106 if (It != FirstSpecialInsts.end() && It->second == Inst)
107 FirstSpecialInsts.erase(It);
108}
109
111 for (const auto *U : Inst->users()) {
114 }
115}
116
118 FirstSpecialInsts.clear();
119#ifndef NDEBUG
120
121 validateAll();
122#endif
123}
124
134
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< bool > ExpensiveAsserts("ipt-expensive-asserts", cl::desc("Perform expensive assert validation on every query to Instruction" " Precedence Tracking"), cl::init(false), cl::Hidden)
LLVM Basic Block Representation.
bool isSpecialInstruction(const Instruction *Insn) const override
A predicate that defines whether or not the instruction Insn is considered special and needs to be tr...
Definition InstructionPrecedenceTracking.cpp:125
LLVM_ABI void clear()
Invalidates all information from this tracking.
Definition InstructionPrecedenceTracking.cpp:117
LLVM_ABI void removeUsersOf(const Instruction *Inst)
Notifies this tracking that we are going to replace all uses of Inst.
Definition InstructionPrecedenceTracking.cpp:110
LLVM_ABI void insertInstructionTo(const Instruction *Inst, const BasicBlock *BB)
Notifies this tracking that we are going to insert a new instruction Inst to the basic block BB.
Definition InstructionPrecedenceTracking.cpp:96
LLVM_ABI void removeInstruction(const Instruction *Inst)
Notifies this tracking that we are going to remove the instruction Inst It makes all necessary update...
Definition InstructionPrecedenceTracking.cpp:102
LLVM_ABI const Instruction * getFirstSpecialInstruction(const BasicBlock *BB)
Returns the topmost special instruction from the block BB.
Definition InstructionPrecedenceTracking.cpp:35
virtual bool isSpecialInstruction(const Instruction *Insn) const =0
A predicate that defines whether or not the instruction Insn is considered special and needs to be tr...
LLVM_ABI bool hasSpecialInstructions(const BasicBlock *BB)
Returns true iff at least one instruction from the basic block BB is special.
Definition InstructionPrecedenceTracking.cpp:58
LLVM_ABI bool isPreceededBySpecialInstruction(const Instruction *Insn)
Returns true iff the first special instruction of Insn's block exists and dominates Insn.
Definition InstructionPrecedenceTracking.cpp:63
LLVM_ABI bool mayWriteToMemory() const LLVM_READONLY
Return true if this instruction may modify memory.
LLVM_ABI bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
bool isSpecialInstruction(const Instruction *Insn) const override
A predicate that defines whether or not the instruction Insn is considered special and needs to be tr...
Definition InstructionPrecedenceTracking.cpp:135
iterator_range< user_iterator > users()
const ParentTy * getParent() const
bool match(Val *V, const Pattern &P)
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_IntrinsicIntrinsic::fabs(m_Value(X))
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI bool isGuaranteedToTransferExecutionToSuccessor(const Instruction *I)
Return true if this function can prove that the instruction I will always transfer execution to one o...