#include "llvm/Analysis/InstructionPrecedenceTracking.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/CommandLine.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumInstScanned, "Number of insts scanned while updating ibt");
#ifndef NDEBUG
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);
#endif
const Instruction *InstructionPrecedenceTracking::getFirstSpecialInstruction(
const BasicBlock *BB) { … }
bool InstructionPrecedenceTracking::hasSpecialInstructions(
const BasicBlock *BB) { … }
bool InstructionPrecedenceTracking::isPreceededBySpecialInstruction(
const Instruction *Insn) { … }
void InstructionPrecedenceTracking::fill(const BasicBlock *BB) { … }
#ifndef NDEBUG
void InstructionPrecedenceTracking::validate(const BasicBlock *BB) const {
auto It = FirstSpecialInsts.find(BB);
if (It == FirstSpecialInsts.end())
return;
for (const Instruction &Insn : *BB)
if (isSpecialInstruction(&Insn)) {
assert(It->second == &Insn &&
"Cached first special instruction is wrong!");
return;
}
assert(It->second == nullptr &&
"Block is marked as having special instructions but in fact it has "
"none!");
}
void InstructionPrecedenceTracking::validateAll() const {
for (const auto &It : FirstSpecialInsts)
validate(It.first);
}
#endif
void InstructionPrecedenceTracking::insertInstructionTo(const Instruction *Inst,
const BasicBlock *BB) { … }
void InstructionPrecedenceTracking::removeInstruction(const Instruction *Inst) { … }
void InstructionPrecedenceTracking::removeUsersOf(const Instruction *Inst) { … }
void InstructionPrecedenceTracking::clear() { … }
bool ImplicitControlFlowTracking::isSpecialInstruction(
const Instruction *Insn) const { … }
bool MemoryWriteTracking::isSpecialInstruction(
const Instruction *Insn) const { … }