67 #define DEBUG_TYPE "early-cse" 69 STATISTIC(NumSimplify,
"Number of instructions simplified or DCE'd");
70 STATISTIC(NumCSE,
"Number of instructions CSE'd");
71 STATISTIC(NumCSECVP,
"Number of compare instructions CVP'd");
72 STATISTIC(NumCSELoad,
"Number of load instructions CSE'd");
73 STATISTIC(NumCSECall,
"Number of call instructions CSE'd");
74 STATISTIC(NumDSE,
"Number of trivial dead stores removed");
77 "Controls which instructions are removed");
81 cl::desc(
"Enable imprecision in EarlyCSE in pathological cases, in exchange " 82 "for faster compile. Caps the MemorySSA clobbering calls."));
86 cl::desc(
"Perform extra assertion checking to verify that SimpleValue's hash " 87 "function is well-behaved w.r.t. its isEqual predicate"));
110 if (
CallInst *CI = dyn_cast<CallInst>(Inst))
111 return CI->doesNotAccessMemory() && !CI->getType()->isVoidTy();
112 return isa<CastInst>(Inst) || isa<UnaryOperator>(Inst) ||
113 isa<BinaryOperator>(Inst) || isa<GetElementPtrInst>(Inst) ||
114 isa<CmpInst>(Inst) || isa<SelectInst>(Inst) ||
115 isa<ExtractElementInst>(Inst) || isa<InsertElementInst>(Inst) ||
116 isa<ShuffleVectorInst>(Inst) || isa<ExtractValueInst>(Inst) ||
117 isa<InsertValueInst>(Inst);
134 static unsigned getHashValue(SimpleValue Val);
135 static bool isEqual(SimpleValue LHS, SimpleValue RHS);
207 Value *LHS = BinOp->getOperand(0);
208 Value *RHS = BinOp->getOperand(1);
209 if (BinOp->isCommutative() && BinOp->getOperand(0) > BinOp->getOperand(1))
215 if (
CmpInst *CI = dyn_cast<CmpInst>(Inst)) {
220 Value *LHS = CI->getOperand(0);
221 Value *RHS = CI->getOperand(1);
224 if (std::tie(LHS, Pred) > std::tie(RHS, SwappedPred)) {
268 if (
CastInst *CI = dyn_cast<CastInst>(Inst))
269 return hash_combine(CI->getOpcode(), CI->getType(), CI->getOperand(0));
272 return hash_combine(EVI->getOpcode(), EVI->getOperand(0),
276 return hash_combine(IVI->getOpcode(), IVI->getOperand(0),
280 assert((isa<CallInst>(Inst) || isa<GetElementPtrInst>(Inst) ||
281 isa<ExtractElementInst>(Inst) || isa<InsertElementInst>(Inst) ||
282 isa<ShuffleVectorInst>(Inst) || isa<UnaryOperator>(Inst)) &&
283 "Invalid/unknown instruction");
306 if (LHS.isSentinel() || RHS.isSentinel())
309 if (LHSI->
getOpcode() != RHSI->getOpcode())
316 if (!LHSBinOp->isCommutative())
319 assert(isa<BinaryOperator>(RHSI) &&
320 "same opcode, but different instruction type?");
325 LHSBinOp->getOperand(1) == RHSBinOp->
getOperand(0);
327 if (
CmpInst *LHSCmp = dyn_cast<CmpInst>(LHSI)) {
328 assert(isa<CmpInst>(RHSI) &&
329 "same opcode, but different instruction type?");
330 CmpInst *RHSCmp = cast<CmpInst>(RHSI);
333 LHSCmp->getOperand(1) == RHSCmp->
getOperand(0) &&
334 LHSCmp->getSwappedPredicate() == RHSCmp->
getPredicate();
341 Value *CondL, *CondR, *LHSA, *RHSA, *LHSB, *RHSB;
348 return ((LHSA == RHSA && LHSB == RHSB) ||
349 (LHSA == RHSB && LHSB == RHSA));
353 return LHSA == RHSA && LHSB == RHSB;
357 if (CondL == CondR && LHSA == RHSA && LHSB == RHSB)
379 if (LHSA == RHSB && LHSB == RHSA) {
396 assert(!Result || (LHS.isSentinel() && LHS.Inst == RHS.Inst) ||
446 static unsigned getHashValue(CallValue Val);
447 static bool isEqual(CallValue LHS, CallValue RHS);
462 if (LHS.isSentinel() || RHS.isSentinel())
488 std::unique_ptr<MemorySSAUpdater> MSSAUpdater;
503 ScopedHTType AvailableValues;
521 unsigned Generation = 0;
523 bool IsAtomic =
false;
525 LoadValue() =
default;
526 LoadValue(
Instruction *Inst,
unsigned Generation,
unsigned MatchingId,
528 : DefInst(Inst), Generation(Generation), MatchingId(MatchingId),
529 IsAtomic(IsAtomic) {}
532 using LoadMapAllocator =
539 LoadHTType AvailableLoads;
544 using InvariantMapAllocator =
547 using InvariantHTType =
549 InvariantMapAllocator>;
550 InvariantHTType AvailableInvariants;
558 CallHTType AvailableCalls;
561 unsigned CurrentGeneration = 0;
567 : TLI(TLI), TTI(TTI), DT(DT), AC(AC), SQ(DL, &TLI, &DT, &AC), MSSA(MSSA),
568 MSSAUpdater(std::make_unique<MemorySSAUpdater>(MSSA)) {}
573 unsigned ClobberCounter = 0;
579 NodeScope(ScopedHTType &AvailableValues, LoadHTType &AvailableLoads,
580 InvariantHTType &AvailableInvariants, CallHTType &AvailableCalls)
581 :
Scope(AvailableValues), LoadScope(AvailableLoads),
582 InvariantScope(AvailableInvariants), CallScope(AvailableCalls) {}
583 NodeScope(
const NodeScope &) =
delete;
584 NodeScope &operator=(
const NodeScope &) =
delete;
587 ScopedHTType::ScopeTy
Scope;
588 LoadHTType::ScopeTy LoadScope;
589 InvariantHTType::ScopeTy InvariantScope;
590 CallHTType::ScopeTy CallScope;
599 StackNode(ScopedHTType &AvailableValues, LoadHTType &AvailableLoads,
600 InvariantHTType &AvailableInvariants, CallHTType &AvailableCalls,
603 : CurrentGeneration(cg), ChildGeneration(cg), Node(n), ChildIter(child),
605 Scopes(AvailableValues, AvailableLoads, AvailableInvariants,
608 StackNode(
const StackNode &) =
delete;
609 StackNode &operator=(
const StackNode &) =
delete;
612 unsigned currentGeneration() {
return CurrentGeneration; }
613 unsigned childGeneration() {
return ChildGeneration; }
625 bool isProcessed() {
return Processed; }
626 void process() { Processed =
true; }
629 unsigned CurrentGeneration;
630 unsigned ChildGeneration;
635 bool Processed =
false;
640 class ParseMemoryInst {
646 IsTargetMemInst =
true;
650 if (IsTargetMemInst)
return Info.ReadMem;
651 return isa<LoadInst>(Inst);
655 if (IsTargetMemInst)
return Info.WriteMem;
656 return isa<StoreInst>(Inst);
665 bool isUnordered()
const {
667 return Info.isUnordered();
669 if (
LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
670 return LI->isUnordered();
671 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
672 return SI->isUnordered();
680 return Info.IsVolatile;
682 if (
LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
683 return LI->isVolatile();
684 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
685 return SI->isVolatile();
691 bool isInvariantLoad()
const {
692 if (
auto *LI = dyn_cast<LoadInst>(Inst))
693 return LI->hasMetadata(LLVMContext::MD_invariant_load);
697 bool isMatchingMemLoc(
const ParseMemoryInst &Inst)
const {
699 getMatchingId() == Inst.getMatchingId());
708 int getMatchingId()
const {
709 if (IsTargetMemInst)
return Info.MatchingId;
714 if (IsTargetMemInst)
return Info.PtrVal;
718 bool mayReadFromMemory()
const {
719 if (IsTargetMemInst)
return Info.ReadMem;
720 return Inst->mayReadFromMemory();
723 bool mayWriteToMemory()
const {
724 if (IsTargetMemInst)
return Info.WriteMem;
725 return Inst->mayWriteToMemory();
729 bool IsTargetMemInst =
false;
740 if (
auto *LI = dyn_cast<LoadInst>(Inst))
742 if (
auto *
SI = dyn_cast<StoreInst>(Inst))
743 return SI->getValueOperand();
744 assert(isa<IntrinsicInst>(Inst) &&
"Instruction not supported");
751 bool isOperatingOnInvariantMemAt(
Instruction *I,
unsigned GenAt);
753 bool isSameMemGeneration(
unsigned EarlierGeneration,
unsigned LaterGeneration,
767 MSSAUpdater->removeMemoryAccess(Inst,
true);
789 bool EarlyCSE::isSameMemGeneration(
unsigned EarlierGeneration,
790 unsigned LaterGeneration,
794 if (EarlierGeneration == LaterGeneration)
807 auto *EarlierMA = MSSA->getMemoryAccess(EarlierInst);
810 auto *LaterMA = MSSA->getMemoryAccess(LaterInst);
820 LaterDef = MSSA->getWalker()->getClobberingMemoryAccess(LaterInst);
823 LaterDef = LaterMA->getDefiningAccess();
825 return MSSA->dominates(LaterDef, EarlierMA);
828 bool EarlyCSE::isOperatingOnInvariantMemAt(
Instruction *I,
unsigned GenAt) {
831 if (
auto *LI = dyn_cast<LoadInst>(I))
832 if (LI->hasMetadata(LLVMContext::MD_invariant_load))
841 if (!AvailableInvariants.count(MemLoc))
846 return AvailableInvariants.lookup(MemLoc) <= GenAt;
849 bool EarlyCSE::handleBranchCondition(
Instruction *CondInst,
860 return BOp->getOpcode() == Opcode;
866 unsigned PropagateOpcode =
867 (BI->
getSuccessor(0) == BB) ? Instruction::And : Instruction::Or;
869 bool MadeChanges =
false;
873 while (!WorkList.
empty()) {
876 AvailableValues.insert(Curr, TorF);
878 << Curr->
getName() <<
"' as " << *TorF <<
" in " 891 if (MatchBinOp(Curr, PropagateOpcode))
892 for (
auto &
Op : cast<BinaryOperator>(Curr)->operands())
894 if (SimpleValue::canHandle(OPI) && Visited.
insert(OPI).second)
902 bool Changed =
false;
924 if (CondInst && SimpleValue::canHandle(CondInst))
925 Changed |= handleBranchCondition(CondInst, BI, BB, Pred);
960 if (
match(Inst, m_Intrinsic<Intrinsic::assume>())) {
963 if (CondI && SimpleValue::canHandle(CondI)) {
968 LLVM_DEBUG(
dbgs() <<
"EarlyCSE skipping assumption: " << *Inst <<
'\n');
973 if (
match(Inst, m_Intrinsic<Intrinsic::sideeffect>())) {
974 LLVM_DEBUG(
dbgs() <<
"EarlyCSE skipping sideeffect: " << *Inst <<
'\n');
991 if (
match(Inst, m_Intrinsic<Intrinsic::invariant_start>())) {
995 auto *CI = cast<CallInst>(Inst);
998 if (!AvailableInvariants.count(MemLoc))
999 AvailableInvariants.insert(MemLoc, CurrentGeneration);
1005 dyn_cast<Instruction>(cast<CallInst>(Inst)->getArgOperand(0))) {
1006 if (SimpleValue::canHandle(CondI)) {
1008 if (
auto *KnownCond = AvailableValues.lookup(CondI)) {
1010 if (isa<ConstantInt>(KnownCond) &&
1011 cast<ConstantInt>(KnownCond)->isOne()) {
1013 <<
"EarlyCSE removing guard: " << *Inst <<
'\n');
1020 cast<CallInst>(Inst)->setArgOperand(0, KnownCond);
1031 LastStore =
nullptr;
1038 LLVM_DEBUG(
dbgs() <<
"EarlyCSE Simplify: " << *Inst <<
" to: " << *V
1043 bool Killed =
false;
1062 if (SimpleValue::canHandle(Inst)) {
1064 if (
Value *V = AvailableValues.lookup(Inst)) {
1071 if (
auto *I = dyn_cast<Instruction>(V))
1082 AvailableValues.insert(Inst, Inst);
1086 ParseMemoryInst MemInst(Inst, TTI);
1088 if (MemInst.isValid() && MemInst.isLoad()) {
1091 if (MemInst.isVolatile() || !MemInst.isUnordered()) {
1092 LastStore =
nullptr;
1093 ++CurrentGeneration;
1096 if (MemInst.isInvariantLoad()) {
1103 if (!AvailableInvariants.count(MemLoc))
1104 AvailableInvariants.insert(MemLoc, CurrentGeneration);
1114 LoadValue InVal = AvailableLoads.lookup(MemInst.getPointerOperand());
1115 if (InVal.DefInst !=
nullptr &&
1116 InVal.MatchingId == MemInst.getMatchingId() &&
1118 !MemInst.isVolatile() && MemInst.isUnordered() &&
1120 InVal.IsAtomic >= MemInst.isAtomic() &&
1121 (isOperatingOnInvariantMemAt(Inst, InVal.Generation) ||
1122 isSameMemGeneration(InVal.Generation, CurrentGeneration,
1123 InVal.DefInst, Inst))) {
1125 if (Op !=
nullptr) {
1127 <<
" to: " << *InVal.DefInst <<
'\n');
1143 AvailableLoads.insert(
1144 MemInst.getPointerOperand(),
1145 LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId(),
1146 MemInst.isAtomic()));
1147 LastStore =
nullptr;
1158 !(MemInst.isValid() && !MemInst.mayReadFromMemory()))
1159 LastStore =
nullptr;
1162 if (CallValue::canHandle(Inst)) {
1165 std::pair<Instruction *, unsigned> InVal = AvailableCalls.lookup(Inst);
1166 if (InVal.first !=
nullptr &&
1167 isSameMemGeneration(InVal.second, CurrentGeneration, InVal.first,
1170 <<
" to: " << *InVal.first <<
'\n');
1185 AvailableCalls.insert(
1186 Inst, std::pair<Instruction *, unsigned>(Inst, CurrentGeneration));
1195 if (
FenceInst *FI = dyn_cast<FenceInst>(Inst))
1206 if (MemInst.isValid() && MemInst.isStore()) {
1207 LoadValue InVal = AvailableLoads.lookup(MemInst.getPointerOperand());
1208 if (InVal.DefInst &&
1209 InVal.DefInst == getOrCreateResult(Inst, InVal.DefInst->getType()) &&
1210 InVal.MatchingId == MemInst.getMatchingId() &&
1212 !MemInst.isVolatile() && MemInst.isUnordered() &&
1213 (isOperatingOnInvariantMemAt(Inst, InVal.Generation) ||
1214 isSameMemGeneration(InVal.Generation, CurrentGeneration,
1215 InVal.DefInst, Inst))) {
1222 MemInst.getPointerOperand() ||
1224 "can't have an intervening store if not using MemorySSA!");
1225 LLVM_DEBUG(
dbgs() <<
"EarlyCSE DSE (writeback): " << *Inst <<
'\n');
1244 ++CurrentGeneration;
1246 if (MemInst.isValid() && MemInst.isStore()) {
1255 ParseMemoryInst LastStoreMemInst(LastStore, TTI);
1256 assert(LastStoreMemInst.isUnordered() &&
1257 !LastStoreMemInst.isVolatile() &&
1258 "Violated invariant");
1259 if (LastStoreMemInst.isMatchingMemLoc(MemInst)) {
1261 <<
" due to: " << *Inst <<
'\n');
1265 removeMSSA(LastStore);
1269 LastStore =
nullptr;
1280 AvailableLoads.insert(
1281 MemInst.getPointerOperand(),
1282 LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId(),
1283 MemInst.isAtomic()));
1292 if (MemInst.isUnordered() && !MemInst.isVolatile())
1295 LastStore =
nullptr;
1303 bool EarlyCSE::run() {
1309 std::deque<StackNode *> nodesToProcess;
1311 bool Changed =
false;
1314 nodesToProcess.push_back(
new StackNode(
1315 AvailableValues, AvailableLoads, AvailableInvariants, AvailableCalls,
1316 CurrentGeneration, DT.getRootNode(),
1317 DT.getRootNode()->begin(), DT.getRootNode()->end()));
1319 assert(!CurrentGeneration &&
"Create a new EarlyCSE instance to rerun it.");
1322 while (!nodesToProcess.empty()) {
1325 StackNode *NodeToProcess = nodesToProcess.back();
1328 CurrentGeneration = NodeToProcess->currentGeneration();
1331 if (!NodeToProcess->isProcessed()) {
1333 Changed |= processNode(NodeToProcess->node());
1334 NodeToProcess->childGeneration(CurrentGeneration);
1335 NodeToProcess->process();
1336 }
else if (NodeToProcess->childIter() != NodeToProcess->end()) {
1339 nodesToProcess.push_back(
1340 new StackNode(AvailableValues, AvailableLoads, AvailableInvariants,
1341 AvailableCalls, NodeToProcess->childGeneration(),
1342 child, child->
begin(), child->
end()));
1346 delete NodeToProcess;
1347 nodesToProcess.pop_back();
1385 template<
bool UseMemorySSA>
1398 if (skipFunction(F))
1401 auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
1402 auto &TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
1403 auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1404 auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
1406 UseMemorySSA ? &getAnalysis<MemorySSAWrapperPass>().getMSSA() :
nullptr;
1443 using EarlyCSEMemSSALegacyPass =
1444 EarlyCSELegacyCommonPass<
true>;
1447 char EarlyCSEMemSSALegacyPass::
ID = 0;
1451 return new EarlyCSEMemSSALegacyPass();
1457 "Early CSE w/ MemorySSA",
false,
false)
Legacy wrapper pass to provide the GlobalsAAResult object.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface ...
void initializeEarlyCSELegacyPassPass(PassRegistry &)
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
A parsed version of the target data layout string in and methods for querying it. ...
const_iterator end(StringRef path)
Get end iterator over path.
static ConstantInt * getFalse(LLVMContext &Context)
static SimpleValue getTombstoneKey()
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
This class is the base class for the comparison instructions.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
class_match< CmpInst > m_Cmp()
Matches any compare instruction and ignore it.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
Atomic ordering constants.
bool VerifyMemorySSA
Enables verification of MemorySSA.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
This is the interface for a simple mod/ref and alias analysis over globals.
An instruction for ordering other memory operations.
void push_back(const T &Elt)
value_op_iterator value_op_begin()
This class represents a function call, abstracting a target machine's calling convention.
An immutable pass that tracks lazily created AssumptionCache objects.
bool mayWriteToMemory() const
Return true if this instruction may modify memory.
static unsigned getHashValueImpl(SimpleValue Val)
A cache of @llvm.assume calls within a function.
Analysis pass providing the TargetTransformInfo.
static CallValue getTombstoneKey()
value_op_iterator value_op_end()
BasicBlock * getSuccessor(unsigned i) const
STATISTIC(NumFunctions, "Total number of functions")
Analysis pass which computes a DominatorTree.
block Block Frequency true
An instruction for reading from memory.
Value * getCondition() const
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
This defines the Use class.
static Optional< MemoryLocation > getOrNone(const Instruction *Inst)
unsigned replaceDominatedUsesWith(Value *From, Value *To, DominatorTree &DT, const BasicBlockEdge &Edge)
Replace each use of 'From' with 'To' if that use is dominated by the given edge.
LLVMContext & getContext() const
Get the context in which this basic block lives.
cst_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
iterator begin()
Instruction iterator methods.
bool isIdenticalTo(const Instruction *I) const
Return true if the specified instruction is exactly identical to the current one. ...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
bool match(Val *V, const Pattern &P)
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Legacy analysis pass which computes MemorySSA.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE, etc.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
This is the base class for all instructions that perform data casts.
separate const offset from Split GEPs to a variadic base and a constant offset for better CSE
Encapsulates MemorySSA, including all data associated with memory accesses.
static bool isLoad(int Opcode)
static CallValue getEmptyKey()
RecyclingAllocator - This class wraps an Allocator, adding the functionality of recycling deleted obj...
static MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo *TLI)
Return a location representing a particular argument of a call.
This file provides an implementation of debug counters.
static void cse(BasicBlock *BB)
Perform cse of induction variable instructions.
static bool matchSelectWithOptionalNotCond(Value *V, Value *&Cond, Value *&A, Value *&B, SelectPatternFlavor &Flavor)
Match a 'select' including an optional 'not's of the condition.
Type * getType() const
All values are typed, get the type of this value.
static bool isEqual(const Function &Caller, const Function &Callee)
This file provides the interface for a simple, fast CSE pass.
static cl::opt< bool > EarlyCSEDebugHash("earlycse-debug-hash", cl::init(false), cl::Hidden, cl::desc("Perform extra assertion checking to verify that SimpleValue's hash " "function is well-behaved w.r.t. its isEqual predicate"))
void salvageDebugInfoOrMarkUndef(Instruction &I)
Salvage all debug users of the instruction I or mark it as undef if it cannot be salvaged.
void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction...
static bool isStore(int Opcode)
static cl::opt< unsigned > EarlyCSEMssaOptCap("earlycse-mssa-optimization-cap", cl::init(500), cl::Hidden, cl::desc("Enable imprecision in EarlyCSE in pathological cases, in exchange " "for faster compile. Caps the MemorySSA clobbering calls."))
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Optimize for code generation
INITIALIZE_PASS_BEGIN(EarlyCSELegacyPass, "early-cse", "Early CSE", false, false) using EarlyCSEMemSSALegacyPass
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Value * getOperand(unsigned i) const
Analysis containing CSE Info
bool isVoidTy() const
Return true if this is 'void'.
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
static bool runOnFunction(Function &F, bool PostInlining)
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
initializer< Ty > init(const Ty &Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A set of analyses that are preserved following a run of a transformation pass.
const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
bool isIdenticalToWhenDefined(const Instruction *I) const
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags, which may specify conditions under which the instruction's result is undefined.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Conditional or Unconditional Branch instruction.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static SimpleValue getEmptyKey()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool mayThrow() const
Return true if this instruction may throw an exception.
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
Represent the analysis usage information of a pass.
Analysis pass providing a never-invalidated alias analysis result.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
FunctionPass class - This class is used to implement most global optimizations.
static bool shouldExecute(unsigned CounterName)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
static bool isAtomic(Instruction *I)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
Representation for a specific memory location.
A function analysis which provides an AssumptionCache.
Iterator for intrusive lists based on ilist_node.
void verifyMemorySSA() const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SelectPatternFlavor
Specific patterns of select instructions we can match.
Provides information about what library functions are available for the current target.
An analysis that produces MemorySSA for a function.
LLVM_NODISCARD T pop_back_val()
bool isConditional() const
void setPreservesCFG()
This function should be called by the pass, iff they do not:
static ConstantInt * getTrue(LLVMContext &Context)
bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental.guard intrinsic.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
BinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub > m_Neg(const ValTy &V)
Matches a 'Neg' as 'sub 0, V'.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Represents analyses that only rely on functions' control flow.
Predicate getPredicate() const
Return the predicate for this instruction.
LLVM_NODISCARD bool empty() const
void preserveSet()
Mark an analysis set as preserved.
StringRef getName() const
Return a constant reference to the value's name.
bool onlyReadsMemory(unsigned OpNo) const
bool mayReadFromMemory() const
Return true if this instruction may read memory.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static bool isEqualImpl(SimpleValue LHS, SimpleValue RHS)
void preserve()
Mark an analysis as preserved.
DEBUG_COUNTER(CSECounter, "early-cse", "Controls which instructions are removed")
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
EarlyCSELegacyCommonPass< false > EarlyCSELegacyPass
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isSentinel(const DWARFDebugNames::AttributeEncoding &AE)
Module * getParent()
Get the module that this global value is contained inside of...
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction has no side ef...
LLVM Value Representation.
typename std::vector< DomTreeNodeBase *>::iterator iterator
void initializeEarlyCSEMemSSALegacyPassPass(PassRegistry &)
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
A container for analyses that lazily runs them and caches their results.
Legacy analysis pass which computes a DominatorTree.
static bool isVolatile(Instruction *Inst)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
This header defines various interfaces for pass management in LLVM.
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
Information about a load/store intrinsic defined by the target.
BinaryOp_match< ValTy, cst_pred_ty< is_all_ones >, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
A wrapper class for inspecting calls to intrinsic functions.
This instruction inserts a struct field of array element value into an aggregate value.
CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate > m_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R)