003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/Transforms/Utils
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
Transforms
/
Utils
/
📁
..
📄
AMDGPUEmitPrintf.h
(864 B)
📄
ASanStackFrameLayout.h
(3.51 KB)
📄
AddDiscriminators.h
(1.04 KB)
📄
AssumeBundleBuilder.h
(2.29 KB)
📄
BasicBlockUtils.h
(20.81 KB)
📄
BreakCriticalEdges.h
(1.16 KB)
📄
BuildLibCalls.h
(9.67 KB)
📄
BypassSlowDivision.h
(2.55 KB)
📄
CallGraphUpdater.h
(3.84 KB)
📄
CallPromotionUtils.h
(3.41 KB)
📄
CanonicalizeAliases.h
(998 B)
📄
CanonicalizeFreezeInLoops.h
(1.15 KB)
📄
Cloning.h
(12.34 KB)
📄
CodeExtractor.h
(9.58 KB)
📄
CodeMoverUtils.h
(2.85 KB)
📄
CtorUtils.h
(1021 B)
📄
Debugify.h
(3.36 KB)
📄
EntryExitInstrumenter.h
(1.16 KB)
📄
EscapeEnumerator.h
(1.56 KB)
📄
Evaluator.h
(4.69 KB)
📄
FunctionComparator.h
(17.12 KB)
📄
FunctionImportUtils.h
(5.73 KB)
📄
GlobalStatus.h
(2.97 KB)
📄
GuardUtils.h
(1.92 KB)
📄
ImportedFunctionsInliningStatistics.h
(4.35 KB)
📄
InjectTLIMappings.h
(1.27 KB)
📄
IntegerDivision.h
(2.88 KB)
📄
LCSSA.h
(1.56 KB)
📄
LibCallsShrinkWrap.h
(908 B)
📄
Local.h
(24.77 KB)
📄
LoopRotationUtils.h
(1.54 KB)
📄
LoopSimplify.h
(2.85 KB)
📄
LoopUtils.h
(21.25 KB)
📄
LoopVersioning.h
(5.87 KB)
📄
LowerInvoke.h
(1.08 KB)
📄
LowerMemIntrinsics.h
(2.14 KB)
📄
Mem2Reg.h
(921 B)
📄
MisExpect.h
(1.81 KB)
📄
ModuleUtils.h
(5.04 KB)
📄
NameAnonGlobals.h
(1.03 KB)
📄
PredicateInfo.h
(7.76 KB)
📄
PromoteMemToReg.h
(1.57 KB)
📄
SSAUpdater.h
(6.12 KB)
📄
SSAUpdaterBulk.h
(3.18 KB)
📄
SSAUpdaterImpl.h
(15.75 KB)
📄
SanitizerStats.h
(1.53 KB)
📄
ScalarEvolutionExpander.h
(17.87 KB)
📄
SimplifyIndVar.h
(2.12 KB)
📄
SimplifyLibCalls.h
(10.85 KB)
📄
SizeOpts.h
(4.84 KB)
📄
SplitModule.h
(1.53 KB)
📄
SymbolRewriter.h
(5.02 KB)
📄
UnifyFunctionExitNodes.h
(1.83 KB)
📄
UniqueInternalLinkageNames.h
(1.07 KB)
📄
UnrollLoop.h
(6.05 KB)
📄
VNCoercion.h
(4.99 KB)
📄
ValueMapper.h
(11.67 KB)
Editing: PredicateInfo.h
//===- PredicateInfo.h - Build PredicateInfo ----------------------*-C++-*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// This file implements the PredicateInfo analysis, which creates an Extended /// SSA form for operations used in branch comparisons and llvm.assume /// comparisons. /// /// Copies of these operations are inserted into the true/false edge (and after /// assumes), and information attached to the copies. All uses of the original /// operation in blocks dominated by the true/false edge (and assume), are /// replaced with uses of the copies. This enables passes to easily and sparsely /// propagate condition based info into the operations that may be affected. /// /// Example: /// %cmp = icmp eq i32 %x, 50 /// br i1 %cmp, label %true, label %false /// true: /// ret i32 %x /// false: /// ret i32 1 /// /// will become /// /// %cmp = icmp eq i32, %x, 50 /// br i1 %cmp, label %true, label %false /// true: /// %x.0 = call \@llvm.ssa_copy.i32(i32 %x) /// ret i32 %x.0 /// false: /// ret i32 1 /// /// Using getPredicateInfoFor on x.0 will give you the comparison it is /// dominated by (the icmp), and that you are located in the true edge of that /// comparison, which tells you x.0 is 50. /// /// In order to reduce the number of copies inserted, predicateinfo is only /// inserted where it would actually be live. This means if there are no uses of /// an operation dominated by the branch edges, or by an assume, the associated /// predicate info is never inserted. /// /// //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_UTILS_PREDICATEINFO_H #define LLVM_TRANSFORMS_UTILS_PREDICATEINFO_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/PassManager.h" #include "llvm/IR/Value.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" namespace llvm { class AssumptionCache; class DominatorTree; class Function; class IntrinsicInst; class raw_ostream; enum PredicateType { PT_Branch, PT_Assume, PT_Switch }; // Base class for all predicate information we provide. // All of our predicate information has at least a comparison. class PredicateBase : public ilist_node<PredicateBase> { public: PredicateType Type; // The original operand before we renamed it. // This can be use by passes, when destroying predicateinfo, to know // whether they can just drop the intrinsic, or have to merge metadata. Value *OriginalOp; // The renamed operand in the condition used for this predicate. For nested // predicates, this is different to OriginalOp which refers to the initial // operand. Value *RenamedOp; PredicateBase(const PredicateBase &) = delete; PredicateBase &operator=(const PredicateBase &) = delete; PredicateBase() = delete; virtual ~PredicateBase() = default; protected: PredicateBase(PredicateType PT, Value *Op) : Type(PT), OriginalOp(Op) {} }; class PredicateWithCondition : public PredicateBase { public: Value *Condition; static bool classof(const PredicateBase *PB) { return PB->Type == PT_Assume || PB->Type == PT_Branch || PB->Type == PT_Switch; } protected: PredicateWithCondition(PredicateType PT, Value *Op, Value *Condition) : PredicateBase(PT, Op), Condition(Condition) {} }; // Provides predicate information for assumes. Since assumes are always true, // we simply provide the assume instruction, so you can tell your relative // position to it. class PredicateAssume : public PredicateWithCondition { public: IntrinsicInst *AssumeInst; PredicateAssume(Value *Op, IntrinsicInst *AssumeInst, Value *Condition) : PredicateWithCondition(PT_Assume, Op, Condition), AssumeInst(AssumeInst) {} PredicateAssume() = delete; static bool classof(const PredicateBase *PB) { return PB->Type == PT_Assume; } }; // Mixin class for edge predicates. The FROM block is the block where the // predicate originates, and the TO block is the block where the predicate is // valid. class PredicateWithEdge : public PredicateWithCondition { public: BasicBlock *From; BasicBlock *To; PredicateWithEdge() = delete; static bool classof(const PredicateBase *PB) { return PB->Type == PT_Branch || PB->Type == PT_Switch; } protected: PredicateWithEdge(PredicateType PType, Value *Op, BasicBlock *From, BasicBlock *To, Value *Cond) : PredicateWithCondition(PType, Op, Cond), From(From), To(To) {} }; // Provides predicate information for branches. class PredicateBranch : public PredicateWithEdge { public: // If true, SplitBB is the true successor, otherwise it's the false successor. bool TrueEdge; PredicateBranch(Value *Op, BasicBlock *BranchBB, BasicBlock *SplitBB, Value *Condition, bool TakenEdge) : PredicateWithEdge(PT_Branch, Op, BranchBB, SplitBB, Condition), TrueEdge(TakenEdge) {} PredicateBranch() = delete; static bool classof(const PredicateBase *PB) { return PB->Type == PT_Branch; } }; class PredicateSwitch : public PredicateWithEdge { public: Value *CaseValue; // This is the switch instruction. SwitchInst *Switch; PredicateSwitch(Value *Op, BasicBlock *SwitchBB, BasicBlock *TargetBB, Value *CaseValue, SwitchInst *SI) : PredicateWithEdge(PT_Switch, Op, SwitchBB, TargetBB, SI->getCondition()), CaseValue(CaseValue), Switch(SI) {} PredicateSwitch() = delete; static bool classof(const PredicateBase *PB) { return PB->Type == PT_Switch; } }; /// Encapsulates PredicateInfo, including all data associated with memory /// accesses. class PredicateInfo { public: PredicateInfo(Function &, DominatorTree &, AssumptionCache &); ~PredicateInfo(); void verifyPredicateInfo() const; void dump() const; void print(raw_ostream &) const; const PredicateBase *getPredicateInfoFor(const Value *V) const { return PredicateMap.lookup(V); } protected: // Used by PredicateInfo annotater, dumpers, and wrapper pass. friend class PredicateInfoAnnotatedWriter; friend class PredicateInfoPrinterLegacyPass; friend class PredicateInfoBuilder; private: Function &F; // This owns the all the predicate infos in the function, placed or not. iplist<PredicateBase> AllInfos; // This maps from copy operands to Predicate Info. Note that it does not own // the Predicate Info, they belong to the ValueInfo structs in the ValueInfos // vector. DenseMap<const Value *, const PredicateBase *> PredicateMap; // The set of ssa_copy declarations we created with our custom mangling. SmallSet<AssertingVH<Function>, 20> CreatedDeclarations; }; // This pass does eager building and then printing of PredicateInfo. It is used // by // the tests to be able to build, dump, and verify PredicateInfo. class PredicateInfoPrinterLegacyPass : public FunctionPass { public: PredicateInfoPrinterLegacyPass(); static char ID; bool runOnFunction(Function &) override; void getAnalysisUsage(AnalysisUsage &AU) const override; }; /// Printer pass for \c PredicateInfo. class PredicateInfoPrinterPass : public PassInfoMixin<PredicateInfoPrinterPass> { raw_ostream &OS; public: explicit PredicateInfoPrinterPass(raw_ostream &OS) : OS(OS) {} PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; /// Verifier pass for \c PredicateInfo. struct PredicateInfoVerifierPass : PassInfoMixin<PredicateInfoVerifierPass> { PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); }; } // end namespace llvm #endif // LLVM_TRANSFORMS_UTILS_PREDICATEINFO_H
Upload File
Create Folder