13#ifndef LLVM_TRANSFORMS_UTILS_EVALUATOR_H
14#define LLVM_TRANSFORMS_UTILS_EVALUATOR_H
38 struct MutableAggregate;
50 MutableValue(
const MutableValue &) =
delete;
51 MutableValue(MutableValue &&
Other) {
55 ~MutableValue() { clear(); }
73 struct MutableAggregate {
77 MutableAggregate(
Type *Ty) : Ty(Ty) {}
84 : DL(DL), GetTLI(GetTLI) {
85 ValueStack.emplace_back();
89 for (
auto &Tmp : AllocaTmps)
93 if (!Tmp->use_empty())
105 for (
const auto &Pair : MutatedMemory)
106 Result[Pair.first] = Pair.second.toConstant();
117 bool &StrippedPointerCastsForAliasAnalysis);
121 Constant *R = ValueStack.back().lookup(
V);
122 assert(R &&
"Reference to an uncomputed value!");
126 void setVal(Value *
V, Constant *
C) {
127 ValueStack.back()[
V] =
C;
131 Function *getCalleeWithFormalArgs(CallBase &CB,
132 SmallVectorImpl<Constant *> &Formals);
136 bool getFormalParams(CallBase &CB,
Function *
F,
137 SmallVectorImpl<Constant *> &Formals);
140 Constant *ComputeLoadResult(GlobalVariable *GV,
Type *Ty,
146 std::deque<DenseMap<Value*, Constant*>> ValueStack;
155 DenseMap<GlobalVariable *, MutableValue> MutatedMemory;
164 SmallPtrSet<GlobalVariable*, 8> Invariants;
168 SmallPtrSet<Constant*, 8> SimpleConstants;
170 const DataLayout &DL;
171 function_ref<TargetLibraryInfo &(
Function &)> GetTLI;
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the DenseMap class.
static bool getVal(MDTuple *MD, const char *Key, uint64_t &Val)
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
Class for arbitrary precision integers.
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
This is an important base class in LLVM.
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
Evaluator(const DataLayout &DL, const function_ref< TargetLibraryInfo &(Function &)> GetTLI)
DenseMap< GlobalVariable *, Constant * > getMutatedInitializers() const
LLVM_ABI bool EvaluateFunction(Function *F, Constant *&RetVal, const SmallVectorImpl< Constant * > &ActualArgs)
Evaluate a call to function F, returning true if successful, false if we can't evaluate it.
const SmallPtrSetImpl< GlobalVariable * > & getInvariants() const
A discriminated union of two or more pointer types, with the discriminator in the low bits of the poi...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Error write(DWPWriter &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue, Dwarf64StrOffsetsPromotion StrOffsetsOptValue, raw_pwrite_stream *OS=nullptr)