Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
Macros |Typedefs |Functions |Variables
Local.cpp File Reference
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AssumeBundleQueries.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/EHPersonalities.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/IRBuilder.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/IntrinsicsWebAssembly.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <map>
#include <optional>
#include <utility>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "local"
 

Typedefs

using PredBlockVector =SmallVector<BasicBlock *, 16 >
 
using IncomingValueMap =SmallDenseMap<BasicBlock *,Value *, 16 >
 
using DbgValReplacement = std::optional<DIExpression * >
 A replacement for a dbg.value expression.
 

Functions

 STATISTIC (NumRemoved, "Number of unreachable basicblocks removed")
 
 STATISTIC (NumPHICSEs, "Number ofPHI's that gotCSE'd")
 
staticbool areAllUsesEqual (Instruction *I)
 areAllUsesEqual - Check whether the uses of a value are all the same.
 
staticbool simplifyAndDCEInstruction (Instruction *I,SmallSetVector<Instruction *, 16 > &WorkList,constDataLayout &DL,constTargetLibraryInfo *TLI)
 
staticbool CanMergeValues (Value *First,Value *Second)
 Return true if we can choose one of these values to use in place of the other.
 
staticbool CanPropagatePredecessorsForPHIs (BasicBlock *BB,BasicBlock *Succ,constSmallPtrSetImpl<BasicBlock * > &BBPreds)
 Return true if we can fold BB, an almost-empty BB ending in an unconditional branch to Succ, into Succ.
 
staticValueselectIncomingValueForBlock (Value *OldVal,BasicBlock *BB,IncomingValueMap &IncomingValues)
 Determines the value to use as the phi node input for a block.
 
static void gatherIncomingValuesToPhi (PHINode *PN,IncomingValueMap &IncomingValues)
 Create a map from block to value for the operands of a given phi.
 
static void replaceUndefValuesInPhi (PHINode *PN,constIncomingValueMap &IncomingValues)
 Replace the incoming undef values to a phi with the values from a block-to-value map.
 
staticbool CanRedirectPredsOfEmptyBBToSucc (BasicBlock *BB,BasicBlock *Succ,constSmallPtrSetImpl<BasicBlock * > &BBPreds,BasicBlock *&CommonPred)
 
staticbool introduceTooManyPhiEntries (BasicBlock *BB,BasicBlock *Succ)
 Check whether removingBB will make the phis in itsSucc have too many incoming entries.
 
static void redirectValuesFromPredecessorsToPhi (BasicBlock *BB,constPredBlockVector &BBPreds,PHINode *PN,BasicBlock *CommonPred)
 Replace a value flowing from a block to a phi with potentially multiple instances of that value flowing from the block's predecessors to the phi.
 
staticbool EliminateDuplicatePHINodesNaiveImpl (BasicBlock *BB,SmallPtrSetImpl<PHINode * > &ToRemove)
 
staticbool EliminateDuplicatePHINodesSetBasedImpl (BasicBlock *BB,SmallPtrSetImpl<PHINode * > &ToRemove)
 
staticbool PhiHasDebugValue (DILocalVariable *DIVar,DIExpression *DIExpr,PHINode *APN)
 ===------------------------------------------------------------------—===// Dbg Intrinsic utilities
 
staticbool valueCoversEntireFragment (Type *ValTy,DbgVariableIntrinsic *DII)
 Check if the alloc size ofValTy is large enough to cover the variable (or fragment of the variable) described byDII.
 
staticbool valueCoversEntireFragment (Type *ValTy,DbgVariableRecord *DVR)
 
static void insertDbgValueOrDbgVariableRecord (DIBuilder &Builder,Value *DV,DILocalVariable *DIVar,DIExpression *DIExpr,constDebugLoc &NewLoc,BasicBlock::iterator Instr)
 
static void insertDbgValueOrDbgVariableRecordAfter (DIBuilder &Builder,Value *DV,DILocalVariable *DIVar,DIExpression *DIExpr,constDebugLoc &NewLoc,BasicBlock::iterator Instr)
 
staticDIExpressiondropInitialDeref (constDIExpression *DIExpr)
 
staticbool isArray (AllocaInst *AI)
 Determine whether this alloca is either a VLA or an array.
 
staticbool isStructure (AllocaInst *AI)
 Determine whether this alloca is a structure.
 
static void insertDbgVariableRecordsForPHIs (BasicBlock *BB,SmallVectorImpl<PHINode * > &InsertedPHIs)
 
static void updateOneDbgValueForAlloca (constDebugLoc &Loc,DILocalVariable *DIVar,DIExpression *DIExpr,Value *NewAddress,DbgValueInst *DVI,DbgVariableRecord *DVR,DIBuilder &Builder, intOffset)
 
template<typenameT >
static void salvageDbgAssignAddress (T *Assign)
 
ValuegetSalvageOpsForGEP (GetElementPtrInst *GEP,constDataLayout &DL,uint64_t CurrentLocOps,SmallVectorImpl<uint64_t > &Opcodes,SmallVectorImpl<Value * > &AdditionalValues)
 
uint64_t getDwarfOpForBinOp (Instruction::BinaryOps Opcode)
 
static void handleSSAValueOperands (uint64_t CurrentLocOps,SmallVectorImpl<uint64_t > &Opcodes,SmallVectorImpl<Value * > &AdditionalValues,Instruction *I)
 
ValuegetSalvageOpsForBinOp (BinaryOperator *BI,uint64_t CurrentLocOps,SmallVectorImpl<uint64_t > &Opcodes,SmallVectorImpl<Value * > &AdditionalValues)
 
uint64_t getDwarfOpForIcmpPred (CmpInst::Predicate Pred)
 
ValuegetSalvageOpsForIcmpOp (ICmpInst *Icmp,uint64_t CurrentLocOps,SmallVectorImpl<uint64_t > &Opcodes,SmallVectorImpl<Value * > &AdditionalValues)
 
staticbool rewriteDebugUsers (Instruction &From,Value &To,Instruction &DomPoint,DominatorTree &DT,function_ref<DbgValReplacement(DbgVariableIntrinsic &DII)> RewriteExpr,function_ref<DbgValReplacement(DbgVariableRecord &DVR)> RewriteDVRExpr)
 Point debug users ofFrom toTo using exprs given byRewriteExpr, possibly moving/undefing users to prevent use-before-def.
 
staticbool isBitCastSemanticsPreserving (constDataLayout &DL,Type *FromTy,Type *ToTy)
 Check if a bitcast between a value of typeFromTy to typeToTy would losslessly preserve the bits and semantics of the value.
 
staticbool markAliveBlocks (Function &F,SmallPtrSetImpl<BasicBlock * > &Reachable,DomTreeUpdater *DTU=nullptr)
 
static void combineMetadata (Instruction *K,constInstruction *J,bool DoesKMove,bool AAOnly=false)
 If AAOnly is set, only intersect alias analysis metadata and preserve other known metadata.
 
template<typename RootType , typename ShouldReplaceFn >
staticunsigned replaceDominatedUsesWith (Value *From,Value *To,const RootType &Root,const ShouldReplaceFn &ShouldReplace)
 
staticconst std::optional< BitPart > & collectBitParts (Value *V,bool MatchBSwaps,bool MatchBitReversals, std::map<Value *, std::optional< BitPart > > &BPS, int Depth,bool &FoundRoot)
 Analyze the specified subexpression and see if it is capable of providing pieces of a bswap or bitreverse.
 
staticbool bitTransformIsCorrectForBSwap (unsignedFrom,unsigned To,unsignedBitWidth)
 
staticbool bitTransformIsCorrectForBitReverse (unsignedFrom,unsigned To,unsignedBitWidth)
 

Variables

cl::opt<boolUseNewDbgInfoFormat
 
staticcl::opt<boolPHICSEDebugHash ("phicse-debug-hash", cl::init(false), cl::Hidden,cl::desc("Perform extra assertion checking toverify that PHINodes's hash " "function is well-behaved w.r.t. itsisEqual predicate"))
 
staticcl::opt<unsignedPHICSENumPHISmallSize ("phicse-num-phi-smallsize", cl::init(32), cl::Hidden,cl::desc("When the basicblockcontains not more than this number ofPHInodes, " "perform a (faster!) exhaustive search instead of set-driven one."))
 
staticcl::opt<unsignedMaxPhiEntriesIncreaseAfterRemovingEmptyBlock ("max-phi-entries-increase-after-removing-empty-block", cl::init(1000), cl::Hidden,cl::desc("Stop removing an emptyblockif removing it will introduce more " "than this number of phi entries in its successor"))
 
staticconstunsigned BitPartRecursionMaxDepth = 48
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "local"

Definition at line93 of fileLocal.cpp.

Typedef Documentation

◆ DbgValReplacement

usingDbgValReplacement = std::optional<DIExpression *>

A replacement for a dbg.value expression.

Definition at line2666 of fileLocal.cpp.

◆ IncomingValueMap

usingIncomingValueMap =SmallDenseMap<BasicBlock *,Value *, 16>

Definition at line928 of fileLocal.cpp.

◆ PredBlockVector

usingPredBlockVector =SmallVector<BasicBlock *, 16>

Definition at line927 of fileLocal.cpp.

Function Documentation

◆ areAllUsesEqual()

staticbool areAllUsesEqual(InstructionI)
static

areAllUsesEqual - Check whether the uses of a value are all the same.

This is similar to Instruction::hasOneUse() except this will also return true when there are no uses or multiple uses that all refer to the same value.

Definition at line638 of fileLocal.cpp.

ReferencesI.

Referenced byllvm::RecursivelyDeleteDeadPHINode().

◆ bitTransformIsCorrectForBitReverse()

staticbool bitTransformIsCorrectForBitReverse(unsigned From,
unsigned To,
unsigned BitWidth 
)
static

Definition at line4091 of fileLocal.cpp.

Referencesllvm::BitWidth, andFrom.

Referenced byllvm::recognizeBSwapOrBitReverseIdiom().

◆ bitTransformIsCorrectForBSwap()

staticbool bitTransformIsCorrectForBSwap(unsigned From,
unsigned To,
unsigned BitWidth 
)
static

Definition at line4080 of fileLocal.cpp.

Referencesllvm::BitWidth, andFrom.

Referenced byllvm::recognizeBSwapOrBitReverseIdiom().

◆ CanMergeValues()

staticbool CanMergeValues(ValueFirst,
ValueSecond 
)
static

Return true if we can choose one of these values to use in place of the other.

Note that we will always choose the non-undef value to keep.

Definition at line862 of fileLocal.cpp.

Referencesllvm::First.

Referenced byCanPropagatePredecessorsForPHIs().

◆ CanPropagatePredecessorsForPHIs()

staticbool CanPropagatePredecessorsForPHIs(BasicBlockBB,
BasicBlockSucc,
constSmallPtrSetImpl<BasicBlock * > & BBPreds 
)
static

Return true if we can fold BB, an almost-empty BB ending in an unconditional branch to Succ, into Succ.

Assumption: Succ is the single successor for BB.

Definition at line871 of fileLocal.cpp.

Referencesassert(),llvm::BasicBlock::begin(),CanMergeValues(),llvm::SmallPtrSetImpl< PtrType >::count(),llvm::dbgs(),llvm::PHINode::getIncomingBlock(),llvm::PHINode::getIncomingValue(),llvm::PHINode::getIncomingValueForBlock(),llvm::Value::getName(),llvm::PHINode::getNumIncomingValues(),llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(),llvm::BasicBlock::getSinglePredecessor(),I,LLVM_DEBUG, andllvm::succ_begin().

Referenced byllvm::TryToSimplifyUncondBranchFromEmptyBlock().

◆ CanRedirectPredsOfEmptyBBToSucc()

staticbool CanRedirectPredsOfEmptyBBToSucc(BasicBlockBB,
BasicBlockSucc,
constSmallPtrSetImpl<BasicBlock * > & BBPreds,
BasicBlock *& CommonPred 
)
static

Definition at line1024 of fileLocal.cpp.

Referencesllvm::any_of(),llvm::SmallPtrSetImpl< PtrType >::count(),llvm::BasicBlock::getTerminator(),llvm::BasicBlock::hasNPredecessorsOrMore(),llvm::BasicBlock::phis(), andllvm::predecessors().

Referenced byllvm::TryToSimplifyUncondBranchFromEmptyBlock().

◆ collectBitParts()

staticconst std::optional< BitPart > & collectBitParts(ValueV,
bool MatchBSwaps,
bool MatchBitReversals,
std::map<Value *, std::optional< BitPart > > & BPS,
int Depth,
boolFoundRoot 
)
static

Analyze the specified subexpression and see if it is capable of providing pieces of a bswap or bitreverse.

The subexpression provides a potential piece of a bswap or bitreverse if it can be proved that each non-zero bit in the output of the expression came from a corresponding bit in some other value. This function is recursive, and the end result is a mapping of bitnumber to bitnumber. It is the caller's responsibility to validate that the bitnumber to bitnumber mapping is correct for a bswap or bitreverse.

For example, if the current subexpression if "(shl i32 %X, 24)" then we know that the expression deposits the low byte of X into the high byte of the result and that all other bits are zero. This expression is accepted and a BitPart is returned with Provider set to X and Provenance[24-31] set to [0-7].

For vector types, all analysis is performed at the per-element level. No cross-element analysis is supported (shuffle/insertion/reduction), and all constant masks must be splatted across all elements.

To avoid revisiting values, the BitPart results are memoized into the provided map. To avoid unnecessary copying of BitParts, BitParts are constructed in-place in theBPS map. Because of thisBPS needs to store BitParts objects, not pointers. As we need the concept of a nullptr BitParts (Value has been analyzed and the analysis failed), we an Optional type instead to provide the same functionality.

Because we pass around references intoBPS, we must use a container that does not invalidate internal references (std::map instead of DenseMap).

Definition at line3860 of fileLocal.cpp.

ReferencesA,B,BitPartRecursionMaxDepth,llvm::BitWidth,llvm::CallingConv::C,collectBitParts(),llvm::dbgs(),llvm::Depth,for(),getIntrinsicID(),llvm::APInt::getZExtValue(),I,LHS,LLVM_DEBUG,llvm::PatternMatch::m_And(),llvm::PatternMatch::m_APInt(),llvm::PatternMatch::m_BitReverse(),llvm::PatternMatch::m_BSwap(),llvm::PatternMatch::m_FShl(),llvm::PatternMatch::m_FShr(),llvm::PatternMatch::m_LogicalShift(),llvm::PatternMatch::m_Or(),llvm::PatternMatch::m_Trunc(),llvm::PatternMatch::m_Value(),llvm::PatternMatch::m_ZExt(),llvm::PatternMatch::match(),P,llvm::APInt::popcount(),RHS,llvm::APInt::uge(),X, andY.

Referenced bycollectBitParts(), andllvm::recognizeBSwapOrBitReverseIdiom().

◆ combineMetadata()

static void combineMetadata(InstructionK,
constInstructionJ,
bool DoesKMove,
bool AAOnly =false 
)
static

If AAOnly is set, only intersect alias analysis metadata and preserve other known metadata.

Unknown metadata is always dropped.

Definition at line3313 of fileLocal.cpp.

Referencesllvm::MMRAMetadata::combine(),llvm::MDNode::getMergedCallsiteMetadata(),llvm::MDNode::getMergedMemProfMetadata(),llvm::MDNode::getMergedProfMetadata(),llvm::Instruction::getMetadata(),llvm::MDNode::getMostGenericAliasScope(),llvm::MDNode::getMostGenericAlignmentOrDereferenceable(),llvm::MDNode::getMostGenericFPMath(),llvm::MDNode::getMostGenericNoaliasAddrspace(),llvm::MDNode::getMostGenericRange(),llvm::MDNode::getMostGenericTBAA(),llvm::MDNode::intersect(),llvm::intersectAccessGroups(), andllvm_unreachable.

Referenced byllvm::combineAAMetadata(), andllvm::combineMetadataForCSE().

◆ dropInitialDeref()

staticDIExpression * dropInitialDeref(constDIExpressionDIExpr)
static

Definition at line1774 of fileLocal.cpp.

Referencesllvm::ArrayRef< T >::drop_front(),llvm::dwarf::DW_OP_LLVM_arg,llvm::MDNode::getContext(), andllvm::DIExpression::getElements().

Referenced byllvm::InsertDebugValueAtStoreLoc().

◆ EliminateDuplicatePHINodesNaiveImpl()

staticbool EliminateDuplicatePHINodesNaiveImpl(BasicBlockBB,
SmallPtrSetImpl<PHINode * > & ToRemove 
)
static

Definition at line1392 of fileLocal.cpp.

Referencesllvm::BasicBlock::begin(),I,llvm::Instruction::isIdenticalToWhenDefined(),llvm::Value::replaceAllUsesWith(), andToRemove.

Referenced byllvm::EliminateDuplicatePHINodes().

◆ EliminateDuplicatePHINodesSetBasedImpl()

staticbool EliminateDuplicatePHINodesSetBasedImpl(BasicBlockBB,
SmallPtrSetImpl<PHINode * > & ToRemove 
)
static

Definition at line1428 of fileLocal.cpp.

Referencesassert(),llvm::BasicBlock::begin(),llvm::PHINode::block_begin(),llvm::PHINode::block_end(),llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::clear(),getHashValueImpl(),llvm::hash_combine(),llvm::hash_combine_range(),I,llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(),isEqual(),isEqualImpl(),isSentinel(),LHS,PHICSEDebugHash,PHICSENumPHISmallSize,llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::reserve(),RHS,ToRemove,llvm::User::value_op_begin(), andllvm::User::value_op_end().

Referenced byllvm::EliminateDuplicatePHINodes().

◆ gatherIncomingValuesToPhi()

static void gatherIncomingValuesToPhi(PHINodePN,
IncomingValueMapIncomingValues 
)
static

Create a map from block to value for the operands of a given phi.

Create a map from block to value for each non-undef value flowing intoPN.

Parameters
PNThe phi we are collecting the map for.
IncomingValues[out] The map from block to value for this phi.

Definition at line967 of fileLocal.cpp.

Referencesllvm::PHINode::getIncomingBlock(),llvm::PHINode::getIncomingValue(),llvm::PHINode::getNumIncomingValues(), andllvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert().

Referenced byredirectValuesFromPredecessorsToPhi().

◆ getDwarfOpForBinOp()

uint64_t getDwarfOpForBinOp(Instruction::BinaryOps Opcode)

Definition at line2487 of fileLocal.cpp.

Referenced bygetSalvageOpsForBinOp().

◆ getDwarfOpForIcmpPred()

uint64_t getDwarfOpForIcmpPred(CmpInst::Predicate Pred)

Definition at line2563 of fileLocal.cpp.

Referencesllvm::CmpInst::ICMP_EQ,llvm::CmpInst::ICMP_NE,llvm::CmpInst::ICMP_SGE,llvm::CmpInst::ICMP_SGT,llvm::CmpInst::ICMP_SLE,llvm::CmpInst::ICMP_SLT,llvm::CmpInst::ICMP_UGE,llvm::CmpInst::ICMP_UGT,llvm::CmpInst::ICMP_ULE, andllvm::CmpInst::ICMP_ULT.

Referenced bygetSalvageOpsForIcmpOp().

◆ getSalvageOpsForBinOp()

Value * getSalvageOpsForBinOp(BinaryOperatorBI,
uint64_t CurrentLocOps,
SmallVectorImpl<uint64_t > & Opcodes,
SmallVectorImpl<Value * > & AdditionalValues 
)

Definition at line2529 of fileLocal.cpp.

Referencesllvm::SmallVectorImpl< T >::append(),llvm::DIExpression::appendOffset(),getDwarfOpForBinOp(),llvm::BinaryOperator::getOpcode(),llvm::User::getOperand(),handleSSAValueOperands(),llvm::Offset, andllvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced byllvm::salvageDebugInfoImpl().

◆ getSalvageOpsForGEP()

Value * getSalvageOpsForGEP(GetElementPtrInstGEP,
constDataLayoutDL,
uint64_t CurrentLocOps,
SmallVectorImpl<uint64_t > & Opcodes,
SmallVectorImpl<Value * > & AdditionalValues 
)

Definition at line2461 of fileLocal.cpp.

Referencesllvm::SmallVectorImpl< T >::append(),llvm::DIExpression::appendOffset(),assert(),llvm::SmallVectorTemplateCommon< T, typename >::begin(),llvm::BitWidth,DL,llvm::dwarf::DW_OP_LLVM_arg,llvm::MapVector< KeyT, ValueT, MapType, VectorType >::empty(),GEP,llvm::APInt::getSExtValue(),llvm::SmallVectorImpl< T >::insert(),llvm::Offset, andllvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced byllvm::salvageDebugInfoImpl().

◆ getSalvageOpsForIcmpOp()

Value * getSalvageOpsForIcmpOp(ICmpInstIcmp,
uint64_t CurrentLocOps,
SmallVectorImpl<uint64_t > & Opcodes,
SmallVectorImpl<Value * > & AdditionalValues 
)

Definition at line2588 of fileLocal.cpp.

ReferencesgetDwarfOpForIcmpPred(),llvm::User::getOperand(),llvm::CmpInst::getPredicate(),handleSSAValueOperands(),llvm::CmpInst::isSigned(), andllvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced byllvm::salvageDebugInfoImpl().

◆ handleSSAValueOperands()

static void handleSSAValueOperands(uint64_t CurrentLocOps,
SmallVectorImpl<uint64_t > & Opcodes,
SmallVectorImpl<Value * > & AdditionalValues,
InstructionI 
)
static

Definition at line2517 of fileLocal.cpp.

Referencesllvm::SmallVectorImpl< T >::append(),llvm::dwarf::DW_OP_LLVM_arg,I, andllvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced bygetSalvageOpsForBinOp(), andgetSalvageOpsForIcmpOp().

◆ insertDbgValueOrDbgVariableRecord()

static void insertDbgValueOrDbgVariableRecord(DIBuilderBuilder,
ValueDV,
DILocalVariableDIVar,
DIExpressionDIExpr,
constDebugLocNewLoc,
BasicBlock::iterator Instr 
)
static

Definition at line1693 of fileLocal.cpp.

Referencesllvm::DebugLoc::get(),llvm::ValueAsMetadata::get(), andUseNewDbgInfoFormat.

Referenced byllvm::ConvertDebugDeclareToDebugValue(),llvm::InsertDebugValueAtStoreLoc(), andllvm::LowerDbgDeclare().

◆ insertDbgValueOrDbgVariableRecordAfter()

static void insertDbgValueOrDbgVariableRecordAfter(DIBuilderBuilder,
ValueDV,
DILocalVariableDIVar,
DIExpressionDIExpr,
constDebugLocNewLoc,
BasicBlock::iterator Instr 
)
static

Definition at line1712 of fileLocal.cpp.

Referencesllvm::DebugLoc::get(),llvm::ValueAsMetadata::get(), andUseNewDbgInfoFormat.

Referenced byllvm::ConvertDebugDeclareToDebugValue().

◆ insertDbgVariableRecordsForPHIs()

static void insertDbgVariableRecordsForPHIs(BasicBlockBB,
SmallVectorImpl<PHINode * > & InsertedPHIs 
)
static

Definition at line2078 of fileLocal.cpp.

Referencesassert(),llvm::DbgVariableRecord::clone(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(),llvm::MapVector< KeyT, ValueT, MapType, VectorType >::end(),llvm::BasicBlock::end(),llvm::filterDbgVars(),llvm::MapVector< KeyT, ValueT, MapType, VectorType >::find(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(),llvm::BasicBlock::getFirstInsertionPt(),llvm::BasicBlock::getFirstNonPHIIt(),I,llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(),llvm::MapVector< KeyT, ValueT, MapType, VectorType >::insert(),llvm::BasicBlock::insertDbgRecordBefore(),llvm::is_contained(),llvm::DbgVariableRecord::location_ops(),PHI,llvm::DbgVariableRecord::replaceVariableLocationOp(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size(), andllvm::SmallVectorBase< Size_T >::size().

Referenced byllvm::insertDebugValuesForPHIs().

◆ introduceTooManyPhiEntries()

staticbool introduceTooManyPhiEntries(BasicBlockBB,
BasicBlockSucc 
)
static

Check whether removingBB will make the phis in itsSucc have too many incoming entries.

This function does not check whetherBB is foldable or not.

Definition at line1057 of fileLocal.cpp.

Referencesllvm::BasicBlock::hasNPredecessors(),MaxPhiEntriesIncreaseAfterRemovingEmptyBlock,llvm::BasicBlock::phis(), andllvm::pred_size().

Referenced byllvm::TryToSimplifyUncondBranchFromEmptyBlock().

◆ isArray()

staticbool isArray(AllocaInstAI)
static

Determine whether this alloca is either a VLA or an array.

Definition at line1947 of fileLocal.cpp.

Referencesllvm::AllocaInst::getAllocatedType(),llvm::AllocaInst::isArrayAllocation(), andllvm::Type::isArrayTy().

Referenced byllvm::LowerDbgDeclare().

◆ isBitCastSemanticsPreserving()

staticbool isBitCastSemanticsPreserving(constDataLayoutDL,
TypeFromTy,
TypeToTy 
)
static

Check if a bitcast between a value of typeFromTy to typeToTy would losslessly preserve the bits and semantics of the value.

This predicate is symmetric, i.e swappingFromTy andToTy should give the same result.

Note thatType::canLosslesslyBitCastTo is not suitable here because it allows semantically unequivalent bitcasts, such as <2 x i64> -> <4 x i32>, and also does not allow lossless pointer <-> integer conversions.

Definition at line2769 of fileLocal.cpp.

ReferencesDL, andllvm::Type::isIntOrPtrTy().

Referenced byllvm::replaceAllDbgUsesWith().

◆ isStructure()

staticbool isStructure(AllocaInstAI)
static

Determine whether this alloca is a structure.

Definition at line1953 of fileLocal.cpp.

Referencesllvm::AllocaInst::getAllocatedType(), andllvm::Type::isStructTy().

Referenced byllvm::LowerDbgDeclare().

◆ markAliveBlocks()

staticbool markAliveBlocks(FunctionF,
SmallPtrSetImpl<BasicBlock * > & Reachable,
DomTreeUpdaterDTU =nullptr 
)
static

Definition at line3038 of fileLocal.cpp.

Referencesllvm::canSimplifyInvokeNoUnwind(),llvm::changeToCall(),llvm::changeToUnreachable(),llvm::ConstantFoldTerminator(),llvm::BranchInst::Create(),llvm::BasicBlock::Create(),llvm::SmallVectorBase< Size_T >::empty(),F,llvm::BasicBlock::getFirstNonPHIIt(),llvm::Value::getName(),llvm::hash_combine_range(),I,II,llvm::SmallPtrSetImpl< PtrType >::insert(),isEqual(),LHS,llvm::PatternMatch::m_CombineOr(),llvm::PatternMatch::m_Undef(),llvm::PatternMatch::m_Zero(),llvm::PatternMatch::match(),llvm::NullPointerIsDefined(),llvm::SmallVectorImpl< T >::pop_back_val(),Ptr,llvm::SmallVectorTemplateBase< T, bool >::push_back(),llvm::BasicBlock::removePredecessor(),RHS,llvm::Successor,llvm::successors(),llvm::User::value_op_begin(), andllvm::User::value_op_end().

Referenced byllvm::removeUnreachableBlocks().

◆ PhiHasDebugValue()

staticbool PhiHasDebugValue(DILocalVariableDIVar,
DIExpressionDIExpr,
PHINodeAPN 
)
static

===------------------------------------------------------------------—===// Dbg Intrinsic utilities

See if there is a dbg.value intrinsic for DIVar for the PHI node.

Definition at line1611 of fileLocal.cpp.

Referencesassert(),llvm::findDbgValues(), andllvm::is_contained().

Referenced byllvm::ConvertDebugDeclareToDebugValue().

◆ redirectValuesFromPredecessorsToPhi()

static void redirectValuesFromPredecessorsToPhi(BasicBlockBB,
constPredBlockVectorBBPreds,
PHINodePN,
BasicBlockCommonPred 
)
static

Replace a value flowing from a block to a phi with potentially multiple instances of that value flowing from the block's predecessors to the phi.

Parameters
BBThe block with the value flowing into the phi.
BBPredsThe predecessors of BB.
PNThe phi that we are updating.
CommonPredThe common predecessor of BB and PN's BasicBlock

Definition at line1089 of fileLocal.cpp.

Referencesllvm::PHINode::addIncoming(),assert(),gatherIncomingValuesToPhi(),llvm::PHINode::getIncomingBlock(),llvm::PHINode::getIncomingValue(),llvm::PHINode::getIncomingValueForBlock(),llvm::PHINode::getNumIncomingValues(),getParent(),llvm::PHINode::removeIncomingValue(),replaceUndefValuesInPhi(), andselectIncomingValueForBlock().

Referenced byllvm::TryToSimplifyUncondBranchFromEmptyBlock().

◆ replaceDominatedUsesWith()

template<typename RootType , typename ShouldReplaceFn >
staticunsigned replaceDominatedUsesWith(ValueFrom,
ValueTo,
const RootType & Root,
const ShouldReplaceFn & ShouldReplace 
)
static

Definition at line3544 of fileLocal.cpp.

Referencesassert(),llvm::dbgs(),From,llvm::Value::getType(),II,LLVM_DEBUG, andllvm::make_early_inc_range().

◆ replaceUndefValuesInPhi()

static void replaceUndefValuesInPhi(PHINodePN,
constIncomingValueMapIncomingValues 
)
static

Replace the incoming undef values to a phi with the values from a block-to-value map.

Parameters
PNThe phi we are replacing the undefs in.
IncomingValuesA map from block to value.

Definition at line983 of fileLocal.cpp.

Referencesllvm::count_if(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(),llvm::UndefValue::get(),llvm::PHINode::getIncomingBlock(),llvm::PHINode::getIncomingValue(),llvm::PHINode::getNumIncomingValues(),llvm::Value::getType(),llvm::SmallVectorTemplateBase< T, bool >::push_back(),llvm::PHINode::setIncomingValue(), andllvm::SmallVectorBase< Size_T >::size().

Referenced byredirectValuesFromPredecessorsToPhi().

◆ rewriteDebugUsers()

staticbool rewriteDebugUsers(InstructionFrom,
ValueTo,
InstructionDomPoint,
DominatorTreeDT,
function_ref<DbgValReplacement(DbgVariableIntrinsic &DII)> RewriteExpr,
function_ref<DbgValReplacement(DbgVariableRecord &DVR)> RewriteDVRExpr 
)
static

Point debug users ofFrom toTo using exprs given byRewriteExpr, possibly moving/undefing users to prevent use-before-def.

Returns true if changes are made.

Definition at line2671 of fileLocal.cpp.

Referencesllvm::SmallPtrSetImpl< PtrType >::count(),llvm::dbgs(),llvm::DominatorTree::dominates(),llvm::SmallPtrSetImplBase::empty(),llvm::SmallVectorBase< Size_T >::empty(),llvm::findDbgUsers(),From,llvm::DbgRecord::getMarker(),llvm::Instruction::getNextNonDebugInstruction(),llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(),llvm::SmallPtrSetImpl< PtrType >::insert(),LLVM_DEBUG,llvm::DbgMarker::MarkedInstr,llvm::Instruction::moveAfter(),llvm::DbgRecord::removeFromParent(),llvm::DbgVariableRecord::replaceVariableLocationOp(),llvm::DbgVariableIntrinsic::replaceVariableLocationOp(),llvm::salvageDebugInfo(),llvm::DbgVariableRecord::setExpression(),llvm::DbgVariableIntrinsic::setExpression(), andUsers.

Referenced byllvm::replaceAllDbgUsesWith().

◆ salvageDbgAssignAddress()

template<typenameT >
static void salvageDbgAssignAddress(TAssign)
static

Definition at line2281 of fileLocal.cpp.

Referencesllvm::DIExpression::appendOpsToArg(),assert(),llvm::SmallVectorBase< Size_T >::empty(),llvm::DIExpression::foldConstantMath(),llvm::DIExpression::getFragmentInfo(),I, andllvm::salvageDebugInfoImpl().

Referenced byllvm::salvageDebugInfoForDbgValues().

◆ selectIncomingValueForBlock()

staticValue * selectIncomingValueForBlock(ValueOldVal,
BasicBlockBB,
IncomingValueMapIncomingValues 
)
static

Determines the value to use as the phi node input for a block.

Select betweenOldVal any value that we know flows fromBB to a particular phi on the basis of which one (if either) is not undef. Update IncomingValues based on the selected value.

Parameters
OldValThe value we are considering selecting.
BBThe block that the value flows in from.
IncomingValuesA map from block-to-value for other phi inputs that we have examined.
Returns
the selected value.

Definition at line942 of fileLocal.cpp.

Referencesassert(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(),llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), andllvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert().

Referenced byredirectValuesFromPredecessorsToPhi().

◆ simplifyAndDCEInstruction()

staticbool simplifyAndDCEInstruction(InstructionI,
SmallSetVector<Instruction *, 16 > & WorkList,
constDataLayoutDL,
constTargetLibraryInfoTLI 
)
static

Definition at line679 of fileLocal.cpp.

ReferencesDL,I,llvm::SetVector< T, Vector, Set, N >::insert(),llvm::isInstructionTriviallyDead(),llvm::salvageDebugInfo(),llvm::simplifyInstruction(), andllvm::Value::use_empty().

Referenced byllvm::SimplifyInstructionsInBlock().

◆ STATISTIC()[1/2]

STATISTIC(NumPHICSEs ,
"Number ofPHI's that gotCSE'd"  
)

◆ STATISTIC()[2/2]

STATISTIC(NumRemoved ,
"Number of unreachable basicblocks removed"  
)

◆ updateOneDbgValueForAlloca()

static void updateOneDbgValueForAlloca(constDebugLocLoc,
DILocalVariableDIVar,
DIExpressionDIExpr,
ValueNewAddress,
DbgValueInstDVI,
DbgVariableRecordDVR,
DIBuilderBuilder,
int Offset 
)
static

Definition at line2224 of fileLocal.cpp.

Referencesassert(),llvm::DIExpression::getElement(),llvm::DIExpression::getNumElements(),llvm::Offset,llvm::DIExpression::prepend(),llvm::DbgVariableRecord::replaceVariableLocationOp(),llvm::DbgVariableIntrinsic::replaceVariableLocationOp(),llvm::DbgVariableRecord::setExpression(), andllvm::DbgVariableIntrinsic::setExpression().

Referenced byllvm::replaceDbgValueForAlloca().

◆ valueCoversEntireFragment()[1/2]

staticbool valueCoversEntireFragment(TypeValTy,
DbgVariableIntrinsicDII 
)
static

Check if the alloc size ofValTy is large enough to cover the variable (or fragment of the variable) described byDII.

This is primarily intended as a helper for the different ConvertDebugDeclareToDebugValue functions. The dbg.declare that is converted describes an alloca'd variable, so we need to use the alloc size of the value when doing the comparison. E.g. an i1 value will be identified as covering an n-bit fragment, if the store size of i1 is at least n bits.

Definition at line1641 of fileLocal.cpp.

Referencesassert(),DL,llvm::DIExpression::getActiveBits(),llvm::Instruction::getDataLayout(),llvm::DbgVariableIntrinsic::getExpression(),llvm::TypeSize::getFixed(),llvm::DbgVariableIntrinsic::getNumVariableLocationOps(),llvm::DbgVariableIntrinsic::getVariable(),llvm::DbgVariableIntrinsic::getVariableLocationOp(), andllvm::DbgVariableIntrinsic::isAddressOfVariable().

Referenced byllvm::ConvertDebugDeclareToDebugValue().

◆ valueCoversEntireFragment()[2/2]

staticbool valueCoversEntireFragment(TypeValTy,
DbgVariableRecordDVR 
)
static

Definition at line1668 of fileLocal.cpp.

Referencesassert(),DL,llvm::DIExpression::getActiveBits(),llvm::Module::getDataLayout(),llvm::DbgVariableRecord::getExpression(),llvm::TypeSize::getFixed(),llvm::DbgRecord::getModule(),llvm::DbgVariableRecord::getNumVariableLocationOps(),llvm::DbgVariableRecord::getVariable(),llvm::DbgVariableRecord::getVariableLocationOp(), andllvm::DbgVariableRecord::isAddressOfVariable().

Variable Documentation

◆ BitPartRecursionMaxDepth

constunsigned BitPartRecursionMaxDepth = 48
static

Definition at line123 of fileLocal.cpp.

Referenced bycollectBitParts().

◆ MaxPhiEntriesIncreaseAfterRemovingEmptyBlock

cl::opt<unsigned > MaxPhiEntriesIncreaseAfterRemovingEmptyBlock("max-phi-entries-increase-after-removing-empty-block", cl::init(1000), cl::Hidden,cl::desc("Stop removing an emptyblockif removing it will introduce more " "than this number of phi entries in its successor"))("max-phi-entries-increase-after-removing-empty-block" ,
cl::init(1000) ,
cl::Hidden ,
cl::desc("Stop removing an emptyblockif removing it will introduce more " "than this number of phi entries in its successor")  
)
static

Referenced byintroduceTooManyPhiEntries().

◆ PHICSEDebugHash

cl::opt<bool > PHICSEDebugHash("phicse-debug-hash", cl::init(false), cl::Hidden,cl::desc("Perform extra assertion checking toverify that PHINodes's hash " "function is well-behaved w.r.t. itsisEqual predicate"))("phicse-debug-hash" ,
cl::init(false) ,
cl::Hidden ,
cl::desc("Perform extra assertion checking toverify that PHINodes's hash " "function is well-behaved w.r.t. itsisEqual predicate")  
)
static

Referenced byllvm::EliminateDuplicatePHINodes(), andEliminateDuplicatePHINodesSetBasedImpl().

◆ PHICSENumPHISmallSize

cl::opt<unsigned > PHICSENumPHISmallSize("phicse-num-phi-smallsize", cl::init(32), cl::Hidden,cl::desc( "When the basicblockcontains not more than this number ofPHInodes, " "perform a (faster!) exhaustive search instead of set-driven one."))("phicse-num-phi-smallsize" ,
cl::init(32) ,
cl::Hidden ,
cl::desc( "When the basicblockcontains not more than this number ofPHInodes, " "perform a (faster!) exhaustive search instead of set-driven one.")  
)
static

Referenced byllvm::EliminateDuplicatePHINodes(), andEliminateDuplicatePHINodesSetBasedImpl().

◆ UseNewDbgInfoFormat

cl::opt<bool> UseNewDbgInfoFormat
extern

Referenced byllvm::ConvertDebugDeclareToDebugValue(),insertDbgValueOrDbgVariableRecord(), andinsertDbgValueOrDbgVariableRecordAfter().


Generated on Sun Jul 20 2025 15:03:41 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp