28#define DEBUG_TYPE "ipt"
29STATISTIC(NumInstScanned,
"Number of insts scanned while updating ibt");
33 "ipt-expensive-asserts",
34 cl::desc(
"Perform expensive assert validation on every query to Instruction"
35 " Precedence Tracking"),
50 auto [It, Inserted] = FirstSpecialInsts.try_emplace(BB);
52 for (
const auto &
I : *BB) {
72 return MaybeFirstSpecial && MaybeFirstSpecial->
comesBefore(Insn);
76void InstructionPrecedenceTracking::validate(
const BasicBlock *BB)
const {
77 auto It = FirstSpecialInsts.find(BB);
79 if (It == FirstSpecialInsts.end())
84 assert(It->second == &Insn &&
85 "Cached first special instruction is wrong!");
89 assert(It->second ==
nullptr &&
90 "Block is marked as having special instructions but in fact it has "
94void InstructionPrecedenceTracking::validateAll()
const {
96 for (
const auto &It : FirstSpecialInsts)
104 FirstSpecialInsts.erase(BB);
109 assert(BB &&
"must be called before instruction is actually removed");
110 auto It = FirstSpecialInsts.find(BB);
111 if (It != FirstSpecialInsts.end() && It->second == Inst)
112 FirstSpecialInsts.erase(It);
116 for (
const auto *U : Inst->
users()) {
117 if (
const auto *UI = dyn_cast<Instruction>(U))
123 FirstSpecialInsts.clear();
142 using namespace PatternMatch;
143 if (
match(Insn, m_Intrinsic<Intrinsic::experimental_widenable_condition>()))
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)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
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...
LLVM_ABI void clear()
Invalidates all information from this tracking.
LLVM_ABI void removeUsersOf(const Instruction *Inst)
Notifies this tracking that we are going to replace all uses of Inst.
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.
LLVM_ABI void removeInstruction(const Instruction *Inst)
Notifies this tracking that we are going to remove the instruction Inst It makes all necessary update...
LLVM_ABI const Instruction * getFirstSpecialInstruction(const BasicBlock *BB)
Returns the topmost special instruction from the block BB.
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.
LLVM_ABI bool isPreceededBySpecialInstruction(const Instruction *Insn)
Returns true iff the first special instruction of Insn's block exists and dominates Insn.
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...
iterator_range< user_iterator > users()
const ParentTy * getParent() const
bool match(Val *V, const Pattern &P)
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
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...