LLVM
17.0.0git
|
#include "llvm/Analysis/LazyValueInfo.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueLattice.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/AssemblyAnnotationWriter.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
Go to the source code of this file.
Namespaces | |
llvm | |
This is an optimization pass for GlobalISel generic memory operations. | |
Macros | |
#define | DEBUG_TYPE "lazy-value-info" |
Typedefs | |
typedef PointerIntPair< Value *, 1, bool > | CondValue |
Variables | |
static const unsigned | MaxProcessedPerValue = 500 |
lazy value | info |
lazy value Lazy Value Information | Analysis |
lazy value Lazy Value Information | false |
print lazy value Lazy Value Info Printer | Pass |
#define DEBUG_TYPE "lazy-value-info" |
Definition at line 44 of file LazyValueInfo.cpp.
typedef PointerIntPair<Value *, 1, bool> CondValue |
Definition at line 1172 of file LazyValueInfo.cpp.
|
static |
Definition at line 636 of file LazyValueInfo.cpp.
References llvm::getUnderlyingObject(), and Ptr.
Referenced by AddNonNullPointersByInstruction().
|
static |
Definition at line 642 of file LazyValueInfo.cpp.
References AddNonNullPointer(), I, MI, and S.
|
static |
Definition at line 1288 of file LazyValueInfo.cpp.
References assert(), DL, llvm::CastInst::getDestTy(), llvm::Constant::getIntegerValue(), llvm::BinaryOperator::getOpcode(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::ValueLatticeElement::getOverdefined(), llvm::ValueLatticeElement::getRange(), isOperationFoldable(), LHS, RHS, llvm::simplifyBinOp(), and llvm::simplifyCastInst().
Referenced by getEdgeValueLocal().
|
static |
Definition at line 801 of file LazyValueInfo.cpp.
References DL, llvm::ValueLatticeElement::getConstantRange(), and llvm::ValueLatticeElement::isConstantRange().
|
static |
Compute the value of Val on the edge BBFrom -> BBTo.
Returns false if Val is not constrained on the edge. Result is unspecified if return value is false.
Definition at line 1322 of file LazyValueInfo.cpp.
References llvm::ValueLatticeElement::asConstantInteger(), assert(), llvm::BitWidth, constantFoldUser(), llvm::ConstantRange::difference(), DL, llvm::ConstantInt::get(), llvm::ValueLatticeElement::get(), llvm::ValueLatticeElement::getConstantRange(), llvm::Value::getContext(), llvm::Module::getDataLayout(), llvm::Type::getInt1Ty(), llvm::Type::getIntegerBitWidth(), llvm::BasicBlock::getModule(), llvm::ValueLatticeElement::getRange(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), getValueFromCondition(), i, isOperationFoldable(), llvm::ValueLatticeElement::isOverdefined(), move, SI, llvm::ConstantRange::unionWith(), and usesOperand().
Referenced by llvm::LazyValueInfo::getConstantRangeAtUse().
|
static |
Definition at line 559 of file LazyValueInfo.cpp.
References llvm::MCID::Call, llvm::getConstantRangeFromMetadata(), llvm::Instruction::getMetadata(), llvm::Instruction::getOpcode(), llvm::ValueLatticeElement::getOverdefined(), llvm::ValueLatticeElement::getRange(), llvm::Value::getType(), and llvm::SPII::Load.
|
static |
This lazily constructs the LazyValueInfoImpl.
Definition at line 1542 of file LazyValueInfo.cpp.
References assert(), DL, llvm::Intrinsic::getName(), and M.
Referenced by llvm::AttributeList::addParamAttribute(), llvm::LazyValueInfo::clear(), llvm::LazyValueInfo::eraseBlock(), llvm::AttributeList::get(), llvm::MDTuple::get(), llvm::LazyValueInfo::getConstant(), llvm::LazyValueInfo::getConstantOnEdge(), llvm::LazyValueInfo::getConstantRange(), llvm::LazyValueInfo::getConstantRangeOnEdge(), llvm::DIAssignID::getDistinct(), llvm::MDTuple::getDistinct(), llvm::MDTuple::getIfExists(), llvm::LazyValueInfo::getPredicateAt(), llvm::LazyValueInfo::getPredicateOnEdge(), llvm::DIAssignID::getTemporary(), llvm::MDTuple::getTemporary(), llvm::LazyValueInfo::printLVI(), llvm::LazyValueInfo::releaseMemory(), llvm::LazyValueInfoWrapperPass::runOnFunction(), and llvm::LazyValueInfo::threadEdge().
|
static |
Definition at line 1737 of file LazyValueInfo.cpp.
References llvm::ConstantFoldCompareInstOperands(), llvm::ConstantRange::contains(), DL, llvm::LazyValueInfo::False, llvm::ValueLatticeElement::getConstant(), llvm::ValueLatticeElement::getConstantRange(), llvm::ValueLatticeElement::getNotConstant(), llvm::ConstantInt::getValue(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::ConstantRange::inverse(), llvm::ValueLatticeElement::isConstant(), llvm::ValueLatticeElement::isConstantRange(), llvm::ValueLatticeElement::isNotConstant(), llvm::Constant::isNullValue(), llvm::ConstantRange::isSingleElement(), llvm::ConstantRange::makeExactICmpRegion(), llvm::LazyValueInfo::True, and llvm::LazyValueInfo::Unknown.
Referenced by llvm::LazyValueInfo::getPredicateAt(), and llvm::LazyValueInfo::getPredicateOnEdge().
|
static |
Definition at line 1240 of file LazyValueInfo.cpp.
References assert(), Cond, llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), llvm::ValueLatticeElement::getOverdefined(), getValueFromConditionImpl(), and llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::try_emplace().
Referenced by llvm::LazyValueInfo::getConstantRangeAtUse(), and getEdgeValueLocal().
|
static |
Definition at line 1174 of file LazyValueInfo.cpp.
References assert(), Cond, llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), llvm::ExtractValueInst::getAggregateOperand(), llvm::PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info >::getInt(), llvm::ExtractValueInst::getNumIndices(), llvm::ValueLatticeElement::getOverdefined(), llvm::PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info >::getPointer(), getValueFromICmpCondition(), getValueFromOverflowCondition(), llvm::ExtractValueInst::idx_begin(), intersect(), llvm::ValueLatticeElement::isOverdefined(), llvm::PatternMatch::m_LogicalAnd(), llvm::PatternMatch::m_LogicalOr(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::ValueLatticeElement::mergeIn(), and N.
Referenced by getValueFromCondition().
|
static |
Definition at line 1081 of file LazyValueInfo.cpp.
References llvm::BitWidth, llvm::ConstantRange::fromKnownBits(), llvm::ValueLatticeElement::get(), llvm::CmpInst::getInversePredicate(), llvm::ConstantRange::getNonEmpty(), llvm::ValueLatticeElement::getNot(), llvm::APInt::getOneBitSet(), llvm::User::getOperand(), llvm::ValueLatticeElement::getOverdefined(), llvm::CmpInst::getPredicate(), llvm::ValueLatticeElement::getRange(), llvm::Type::getScalarSizeInBits(), llvm::CmpInst::getSwappedPredicate(), llvm::Value::getType(), llvm::ConstantRange::getUnsignedMin(), getValueFromSimpleICmpCondition(), llvm::APInt::getZero(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::ConstantRange::isEmptySet(), llvm::ICmpInst::isEquality(), llvm::Type::isIntegerTy(), LHS, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::ConstantRange::makeExactICmpRegion(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), matchICmpOperand(), llvm::Offset, llvm::KnownBits::One, RHS, llvm::KnownBits::Zero, and llvm::APInt::zext().
Referenced by getValueFromConditionImpl().
|
static |
Definition at line 1151 of file LazyValueInfo.cpp.
References llvm::BinaryOpIntrinsic::getBinaryOp(), llvm::BinaryOpIntrinsic::getLHS(), llvm::BinaryOpIntrinsic::getNoWrapKind(), llvm::ValueLatticeElement::getOverdefined(), llvm::ValueLatticeElement::getRange(), llvm::BinaryOpIntrinsic::getRHS(), llvm::ConstantRange::inverse(), llvm::PatternMatch::m_APInt(), llvm::ConstantRange::makeExactNoWrapRegion(), and llvm::PatternMatch::match().
Referenced by getValueFromConditionImpl().
|
static |
Get value range for a "(Val + Offset) Pred RHS" condition.
Definition at line 1066 of file LazyValueInfo.cpp.
References llvm::getConstantRangeFromMetadata(), llvm::Type::getIntegerBitWidth(), llvm::ValueLatticeElement::getRange(), llvm::Value::getType(), I, llvm::ConstantRange::makeAllowedICmpRegion(), llvm::Offset, RHS, and llvm::ConstantRange::subtract().
Referenced by getValueFromICmpCondition().
|
static |
Returns true if this lattice value represents at most one possible value.
This is as precise as any lattice value can get while still representing reachable code.
Definition at line 70 of file LazyValueInfo.cpp.
References llvm::ValueLatticeElement::getConstantRange(), llvm::ValueLatticeElement::isConstant(), llvm::ValueLatticeElement::isConstantRange(), and llvm::ConstantRange::isSingleElement().
Referenced by intersect().
INITIALIZE_PASS_BEGIN | ( | LazyValueInfoPrinter | , |
"print-lazy-value-info" | , | ||
"Lazy Value Info Printer Pass" | , | ||
false | , | ||
false | |||
) |
INITIALIZE_PASS_BEGIN | ( | LazyValueInfoWrapperPass | , |
"lazy-value-info" | , | ||
"Lazy Value Information Analysis" | , | ||
false | , | ||
true | |||
) |
|
static |
Combine two sets of facts about the same value into a single set of facts.
Note that this method is not suitable for merging facts along different paths in a CFG; that's what the mergeIn function is for. This is for merging facts gathered about the same value at the same location through two independent means. Notes:
Definition at line 95 of file LazyValueInfo.cpp.
References B, llvm::ValueLatticeElement::getRange(), hasSingleValue(), and move.
Referenced by getValueFromConditionImpl().
|
static |
Returns true if we can statically tell that this value will never be a "useful" constant.
In practice, this means we've got something like an alloca or a malloc call for which a comparison against a constant can only be guarding dead code. Note that we are potentially giving up some precision in dead code (a constant result) in favour of avoiding a expensive search for a easily answered common query.
Definition at line 1610 of file LazyValueInfo.cpp.
References llvm::Value::stripPointerCasts().
Referenced by llvm::LazyValueInfo::getConstant().
|
static |
Definition at line 1280 of file LazyValueInfo.cpp.
Referenced by constantFoldUser(), and getEdgeValueLocal().
|
static |
Definition at line 1032 of file LazyValueInfo.cpp.
References llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, LHS, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::Offset.
Referenced by getValueFromICmpCondition().
Definition at line 1272 of file LazyValueInfo.cpp.
References llvm::is_contained(), and llvm::User::operands().
Referenced by getEdgeValueLocal().
lazy value Lazy Value Information Analysis |
Definition at line 59 of file LazyValueInfo.cpp.
print lazy value info |
Definition at line 58 of file LazyValueInfo.cpp.
Referenced by ARM64EmitRuntimeFunction(), ARM64EmitUnwindInfo(), ARM64EmitUnwindInfoForSegment(), ARM64FindSegmentsInFunction(), ARM64ProcessEpilogs(), ARMEmitRuntimeFunction(), ARMEmitUnwindInfo(), checkARM64PackedEpilog(), checkARMPackedEpilog(), EmitRuntimeFunction(), llvm::Win64EH::UnwindEmitter::EmitUnwindInfo(), llvm::Win64EH::ARMUnwindEmitter::EmitUnwindInfo(), llvm::Win64EH::ARM64UnwindEmitter::EmitUnwindInfo(), EmitUnwindInfo(), findLiveReferences(), FindMatchingEpilog(), llvm::CCState::getInRegsParamInfo(), llvm::TargetLowering::getMultipleConstraintMatchWeight(), llvm::SparcTargetLowering::getSingleConstraintMatchWeight(), llvm::AVRTargetLowering::getSingleConstraintMatchWeight(), llvm::SystemZTargetLowering::getSingleConstraintMatchWeight(), llvm::ARMTargetLowering::getSingleConstraintMatchWeight(), llvm::PPCTargetLowering::getSingleConstraintMatchWeight(), llvm::X86TargetLowering::getSingleConstraintMatchWeight(), llvm::TargetLowering::getSingleConstraintMatchWeight(), insertParsePoints(), recomputeLiveInValues(), llvm::MachO::swapStruct(), tryARM64PackedUnwind(), and tryARMPackedUnwind().
|
static |
Definition at line 48 of file LazyValueInfo.cpp.
Definition at line 2066 of file LazyValueInfo.cpp.
Referenced by analyzeFunction(), llvm::PreservedCFGCheckerInstrumentation::registerCallbacks(), llvm::slpvectorizer::BoUpSLP::VLOperands::reorder(), llvm::SanitizerBinaryMetadataPass::run(), llvm::PassManager< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & >::run(), llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::runSinglePass(), and llvm::MIRProfileLoader::setFSPass().