LLVM
12.0.0git
|
This class evaluates LLVM IR, producing the Constant representing each SSA instruction. More...
#include "llvm/Transforms/Utils/Evaluator.h"
Public Member Functions | |
Evaluator (const DataLayout &DL, const TargetLibraryInfo *TLI) | |
~Evaluator () | |
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. More... | |
bool | EvaluateBlock (BasicBlock::iterator CurInst, BasicBlock *&NextBB) |
Evaluate all instructions in block BB, returning true if successful, false if we can't evaluate it. More... | |
Constant * | getVal (Value *V) |
void | setVal (Value *V, Constant *C) |
Constant * | castCallResultIfNeeded (Value *CallExpr, Constant *RV) |
Casts call result to a type of bitcast call expression. More... | |
const DenseMap< Constant *, Constant * > & | getMutatedMemory () const |
const SmallPtrSetImpl< GlobalVariable * > & | getInvariants () const |
This class evaluates LLVM IR, producing the Constant representing each SSA instruction.
Changes to global variables are stored in a mapping that can be iterated over after the evaluation is complete. Once an evaluation call fails, the evaluation object should not be reused.
Definition at line 38 of file Evaluator.h.
|
inline |
Definition at line 40 of file Evaluator.h.
References DL.
|
inline |
Definition at line 45 of file Evaluator.h.
References llvm::Constant::getNullValue().
Casts call result to a type of bitcast call expression.
If call expression contains bitcast then we may need to cast evaluated return value to a type of the call expression.
Definition at line 305 of file Evaluator.cpp.
References llvm::ConstantFoldLoadThroughBitcast(), llvm::dbgs(), DL, and LLVM_DEBUG.
Referenced by EvaluateBlock().
bool Evaluator::EvaluateBlock | ( | BasicBlock::iterator | CurInst, |
BasicBlock *& | NextBB | ||
) |
Evaluate all instructions in block BB, returning true if successful, false if we can't evaluate it.
NewBB returns the next BB that control flows into, or null upon return.
Definition at line 322 of file Evaluator.cpp.
References C, Callee, castCallResultIfNeeded(), Cond, llvm::ConstantFoldCall(), llvm::ConstantFoldConstant(), llvm::ConstantFoldLoadThroughBitcast(), llvm::dbgs(), DL, llvm::numbers::e, evaluateBitcastFromPtr(), EvaluateFunction(), GEP, llvm::ConstantExpr::get(), llvm::UndefValue::get(), llvm::CallBase::getCalledOperand(), llvm::ConstantExpr::getCast(), llvm::ConstantExpr::getCompare(), llvm::ConstantExpr::getExtractValue(), llvm::FunctionCallee::getFunctionType(), llvm::ConstantExpr::getGetElementPtr(), llvm::ConstantExpr::getInsertValue(), llvm::Value::getName(), llvm::ConstantExpr::getSelect(), llvm::Value::getType(), getVal(), llvm::GlobalValue::InternalLinkage, llvm::CallBase::isInlineAsm(), isSimpleEnoughPointerToCommit(), isSimpleEnoughValueToCommit(), llvm::FunctionType::isVarArg(), LLVM_DEBUG, llvm::GlobalValue::NotThreadLocal, P, llvm::SmallVectorTemplateBase< T, bool >::push_back(), setVal(), SI, llvm::Check::Size, and llvm::Constant::stripPointerCasts().
Referenced by EvaluateFunction().
bool Evaluator::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.
ActualArgs contains the formal arguments for the function.
Definition at line 669 of file Evaluator.cpp.
References llvm::BasicBlock::begin(), llvm::dbgs(), E, EvaluateBlock(), F(), llvm::PHINode::getIncomingValueForBlock(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::BasicBlock::getTerminator(), getVal(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::is_contained(), LLVM_DEBUG, and setVal().
Referenced by EvaluateBlock(), and EvaluateStaticConstructor().
|
inline |
Definition at line 83 of file Evaluator.h.
Referenced by EvaluateStaticConstructor().
Definition at line 79 of file Evaluator.h.
Referenced by EvaluateStaticConstructor().
Definition at line 65 of file Evaluator.h.
References assert().
Referenced by EvaluateBlock(), and EvaluateFunction().
Definition at line 72 of file Evaluator.h.
References C.
Referenced by EvaluateBlock(), and EvaluateFunction().