|
LLVM
10.0.0
|
#include "llvm/Transforms/Utils/Evaluator.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/CallSite.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Function.h"#include "llvm/IR/GlobalAlias.h"#include "llvm/IR/GlobalValue.h"#include "llvm/IR/GlobalVariable.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/Operator.h"#include "llvm/IR/Type.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/Support/Casting.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include <iterator>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "evaluator" |
Functions | |
| static bool | isSimpleEnoughValueToCommit (Constant *C, SmallPtrSetImpl< Constant *> &SimpleConstants, const DataLayout &DL) |
| static bool | isSimpleEnoughValueToCommitHelper (Constant *C, SmallPtrSetImpl< Constant *> &SimpleConstants, const DataLayout &DL) |
| Return true if the specified constant can be handled by the code generator. More... | |
| static bool | isSimpleEnoughPointerToCommit (Constant *C) |
| Return true if this constant is simple enough for us to understand. More... | |
| static Constant * | evaluateBitcastFromPtr (Constant *Ptr, const DataLayout &DL, const TargetLibraryInfo *TLI, std::function< Constant *(Constant *)> Func) |
| Apply 'Func' to Ptr. More... | |
| static Constant * | getInitializer (Constant *C) |
| static Function * | getFunction (Constant *C) |
| #define DEBUG_TYPE "evaluator" |
Definition at line 43 of file Evaluator.cpp.
|
static |
Apply 'Func' to Ptr.
If this returns nullptr, introspect the pointer's type and walk down through the initial elements to obtain additional pointers to try. Returns the first non-null return value from Func, or nullptr if the type can't be introspected further.
Definition at line 182 of file Evaluator.cpp.
References llvm::ConstantFoldConstant(), llvm::IntegerType::get(), llvm::ConstantInt::get(), llvm::Type::getContext(), llvm::ConstantExpr::getGetElementPtr(), and llvm::Value::getType().
Referenced by llvm::Evaluator::EvaluateBlock(), and getInitializer().
Definition at line 258 of file Evaluator.cpp.
Referenced by llvm::MachineIRBuilder::buildConstant(), computePointerICmp(), llvm::IRPosition::getAnchorScope(), llvm::IRPosition::getAssociatedFunction(), llvm::Evaluator::getCalleeWithFormalArgs(), llvm::LLParser::getContext(), llvm::Instruction::getFunction(), llvm::AMDGPULibFunc::getFunctionType(), llvm::Instruction::getModule(), insertLifetimeMarkersSurroundingCall(), llvm::InstrProfSymtab::isExternalSymbol(), LLVMGetNamedFunction(), llvm::BlockAddress::lookup(), LowerWRITE_REGISTER(), llvm::Constant::needsRelocation(), llvm::DiagnosticInfoResourceLimit::print(), llvm::CallGraphNode::print(), and llvm::CoroIdInst::setCoroutineSelf().
Definition at line 205 of file Evaluator.cpp.
References C, llvm::ConstantFoldLoadThroughBitcast(), llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::dyn_cast(), evaluateBitcastFromPtr(), llvm::Type::getPointerElementType(), llvm::Value::getType(), llvm::GlobalVariable::hasDefinitiveInitializer(), I, and P.
Referenced by splitGlobal().
Return true if this constant is simple enough for us to understand.
In particular, if it is a cast to anything other than from one pointer type to another pointer type, we punt. We basically just support direct accesses to globals and GEP's of globals. This should be kept up to date with CommitValueTo.
Definition at line 131 of file Evaluator.cpp.
References llvm::ConstantFoldLoadThroughGEPConstantExpr(), llvm::dyn_cast(), llvm::GlobalVariable::getInitializer(), llvm::Value::getType(), llvm::GlobalVariable::hasUniqueInitializer(), and llvm::ConstantInt::isZero().
Referenced by llvm::Evaluator::EvaluateBlock().
|
inlinestatic |
Definition at line 116 of file Evaluator.cpp.
References llvm::SmallPtrSetImpl< PtrType >::insert(), and isSimpleEnoughValueToCommitHelper().
Referenced by llvm::Evaluator::EvaluateBlock(), and isSimpleEnoughValueToCommitHelper().
|
static |
Return true if the specified constant can be handled by the code generator.
We don't want to generate something like: void *X = &X/42; because the code generator doesn't have a relocation that can handle that.
This function should be called if C was not found (but just got inserted) in SimpleConstants to avoid having to rescan the same constants all the time.
Definition at line 61 of file Evaluator.cpp.
References llvm::MCID::Add, C, llvm::numbers::e, llvm::User::getNumOperands(), llvm::ConstantExpr::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), isSimpleEnoughValueToCommit(), and llvm::User::operands().
Referenced by isSimpleEnoughValueToCommit().
1.8.13