LLVM: lib/CodeGen/AssignmentTrackingAnalysis.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define DEBUG_TYPE "debug-ata"
Functions
STATISTIC (NumDefsScanned, "Number of dbg locs that get scanned for removal")
STATISTIC (NumDefsRemoved, "Number of dbg locs removed")
STATISTIC (NumWedgesScanned, "Number of dbg wedges scanned")
STATISTIC (NumWedgesChanged, "Number of dbg wedges changed")
static std::pair< Value *, DIExpression * > walkToAllocaAndPrependOffsetDeref (const DataLayout &DL, Value *Start, DIExpression *Expression)
Walk backwards along constant GEPs and bitcasts to the base storage from Start as far as possible.
static std::optional< int64_t > getDerefOffsetInBytes (const DIExpression *DIExpr)
Extract the offset used in DIExpr.
static DebugAggregate getAggregate (const DebugVariable &Var)
static bool shouldCoalesceFragments (Function &F)
static DIAssignID * getIDFromInst (const Instruction &I)
static DIAssignID * getIDFromMarker (const DbgVariableRecord &DVR)
const char * locStr (AssignmentTrackingLowering::LocKind Loc)
VarLocInsertPt getNextNode (const DbgRecord *DVR)
VarLocInsertPt getNextNode (const Instruction *Inst)
VarLocInsertPt getNextNode (VarLocInsertPt InsertPt)
static bool hasZeroSizedFragment (DbgVariableRecord &DbgValue)
static bool fullyContains (DIExpression::FragmentInfo A, DIExpression::FragmentInfo B)
Return true if A fully contains B.
static std::optional< at::AssignmentInfo > getUntaggedStoreAssignmentInfo (const Instruction &I, const DataLayout &Layout)
AllocaInst * getUnknownStore (const Instruction &I, const DataLayout &Layout)
static AssignmentTrackingLowering::OverlapMap buildOverlapMapAndRecordDeclares (Function &Fn, FunctionVarLocsBuilder *FnVarLocs, const DenseSet< DebugAggregate > &VarsWithStackSlot, AssignmentTrackingLowering::UntaggedStoreAssignmentMap &UntaggedStoreVars, AssignmentTrackingLowering::UnknownStoreAssignmentMap &UnknownStoreVars, unsigned &TrackedVariablesVectorSize)
Build a map of {Variable x: Variables y} where all variable fragments contained within the variable fragment x are in set y.
static bool removeRedundantDbgLocsUsingBackwardScan (const BasicBlock *BB, FunctionVarLocsBuilder &FnVarLocs)
Remove redundant definitions within sequences of consecutive location defs.
static bool removeRedundantDbgLocsUsingForwardScan (const BasicBlock *BB, FunctionVarLocsBuilder &FnVarLocs)
Remove redundant location defs using a forward scan.
static bool removeUndefDbgLocsFromEntryBlock (const BasicBlock *BB, FunctionVarLocsBuilder &FnVarLocs)
static bool removeRedundantDbgLocs (const BasicBlock *BB, FunctionVarLocsBuilder &FnVarLocs)
static DenseSet< DebugAggregate > findVarsWithStackSlot (Function &Fn)
static void analyzeFunction (Function &Fn, const DataLayout &Layout, FunctionVarLocsBuilder *FnVarLocs)
Variables
static cl::opt< unsigned > MaxNumBlocks ("debug-ata-max-blocks", cl::init(10000), cl::desc("Maximum num basic blocks before debug info dropped"), cl::Hidden)
static cl::opt< bool > EnableMemLocFragFill ("mem-loc-frag-fill", cl::init(true), cl::Hidden)
Option for debugging the pass, determines if the memory location fragment filling happens after generating the variable locations.
static cl::opt< bool > PrintResults ("print-debug-ata", cl::init(false), cl::Hidden)
Print the results of the analysis. Respects -filter-print-funcs.
static cl::opt< cl::boolOrDefault > CoalesceAdjacentFragmentsOpt ("debug-ata-coalesce-frags", cl::Hidden)
Coalesce adjacent dbg locs describing memory locations that have contiguous fragments.

DEBUG_TYPE

#define DEBUG_TYPE "debug-ata"

DebugAggregate

VarLocInsertPt

analyzeFunction()

buildOverlapMapAndRecordDeclares()

Build a map of {Variable x: Variables y} where all variable fragments contained within the variable fragment x are in set y.

This means that y does not contain all overlaps because partial overlaps are excluded.

While we're iterating over the function, add single location defs for dbg.declares to FnVarLocs.

Variables that are interesting to this pass in are added to FnVarLocs->Variables first. TrackedVariablesVectorSize is set to the ID of the last interesting variable plus 1, meaning variables with ID 1 (inclusive) to TrackedVariablesVectorSize (exclusive) are interesting. The subsequent variables are either stack homed or fully promoted.

Finally, populate UntaggedStoreVars with a mapping of untagged stores to the stored-to variable fragments, and UnknownStoreVars with a mapping of untagged unknown stores to the stored-to variable aggregates.

These tasks are bundled together to reduce the number of times we need to iterate over the function as they can be achieved together in one pass.

Definition at line 2114 of file AssignmentTrackingAnalysis.cpp.

References FunctionVarLocsBuilder::addSingleLocVar(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::at::calculateFragmentIntersect(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::filterDbgVars(), fullyContains(), llvm::Function::getDataLayout(), llvm::DbgRecord::getDebugLoc(), llvm::at::getDVRAssignmentMarkers(), llvm::DbgVariableRecord::getExpression(), llvm::DebugVariable::getInlinedAt(), FunctionVarLocsBuilder::getNumVariables(), llvm::DbgVariableRecord::getRawLocation(), getUnknownStore(), getUntaggedStoreAssignmentInfo(), llvm::DebugVariable::getVariable(), I, Info, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), FunctionVarLocsBuilder::insertVariable(), llvm::Next, and llvm::SmallVectorTemplateBase< T, bool >::push_back().

findVarsWithStackSlot()

fullyContains()

getAggregate()

getDerefOffsetInBytes()

getIDFromInst()

getIDFromMarker()

getNextNode() [1/3]

getNextNode() [2/3]

getNextNode() [3/3]

VarLocInsertPt getNextNode ( VarLocInsertPt InsertPt )

getUnknownStore()

getUntaggedStoreAssignmentInfo()

hasZeroSizedFragment()

locStr()

const char * locStr ( AssignmentTrackingLowering::LocKind Loc )

removeRedundantDbgLocs()

removeRedundantDbgLocsUsingBackwardScan()

Remove redundant definitions within sequences of consecutive location defs.

This is done using a backward scan to keep the last def describing a specific variable/fragment.

This implements removeRedundantDbgInstrsUsingBackwardScan from lib/Transforms/Utils/BasicBlockUtils.cpp for locations described with FunctionVarLocsBuilder instead of with intrinsics.

Definition at line 2461 of file AssignmentTrackingAnalysis.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), Changed, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::divideCeil(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::filterDbgVars(), llvm::BitVector::find_first_unset_in(), getAggregate(), FunctionVarLocsBuilder::getVariable(), FunctionVarLocsBuilder::getWedge(), I, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), llvm::BitVector::set(), FunctionVarLocsBuilder::setWedge(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().

Referenced by removeRedundantDbgLocs().

removeRedundantDbgLocsUsingForwardScan()

Remove redundant location defs using a forward scan.

This can remove a location definition that is redundant due to indicating that a variable has the same value as is already being indicated by an earlier def.

This implements removeRedundantDbgInstrsUsingForwardScan from lib/Transforms/Utils/BasicBlockUtils.cpp for locations described with FunctionVarLocsBuilder instead of with intrinsics

Definition at line 2557 of file AssignmentTrackingAnalysis.cpp.

References Changed, llvm::filterDbgVars(), FunctionVarLocsBuilder::getVariable(), llvm::DebugVariable::getVariable(), FunctionVarLocsBuilder::getWedge(), I, llvm::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key, llvm::SmallVectorTemplateBase< T, bool >::push_back(), FunctionVarLocsBuilder::setWedge(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().

Referenced by removeRedundantDbgLocs().

removeUndefDbgLocsFromEntryBlock()

Definition at line 2616 of file AssignmentTrackingAnalysis.cpp.

References A(), llvm::any_of(), assert(), Changed, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::filterDbgVars(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), FunctionVarLocsBuilder::getVariable(), llvm::DebugVariable::getVariable(), FunctionVarLocsBuilder::getWedge(), I, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), llvm::BasicBlock::isEntryBlock(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and FunctionVarLocsBuilder::setWedge().

Referenced by removeRedundantDbgLocs().

shouldCoalesceFragments()

STATISTIC() [1/4]

STATISTIC ( NumDefsRemoved ,
"Number of dbg locs removed" )

STATISTIC() [2/4]

STATISTIC ( NumDefsScanned ,
"Number of dbg locs that get scanned for removal" )

STATISTIC() [3/4]

STATISTIC ( NumWedgesChanged ,
"Number of dbg wedges changed" )

STATISTIC() [4/4]

STATISTIC ( NumWedgesScanned ,
"Number of dbg wedges scanned" )

walkToAllocaAndPrependOffsetDeref()

CoalesceAdjacentFragmentsOpt

cl::opt< cl::boolOrDefault > CoalesceAdjacentFragmentsOpt("debug-ata-coalesce-frags", cl::Hidden) ( "debug-ata-coalesce-frags" , cl::Hidden ) static

Coalesce adjacent dbg locs describing memory locations that have contiguous fragments.

This reduces the cost of LiveDebugValues which does SSA construction for each explicitly stated variable fragment.

Referenced by shouldCoalesceFragments().

EnableMemLocFragFill

cl::opt< bool > EnableMemLocFragFill("mem-loc-frag-fill", cl::init(true), cl::Hidden) ( "mem-loc-frag-fill" , cl::init(true) , cl::Hidden ) static

Option for debugging the pass, determines if the memory location fragment filling happens after generating the variable locations.

MaxNumBlocks

PrintResults

cl::opt< bool > PrintResults("print-debug-ata", cl::init(false), cl::Hidden) ( "print-debug-ata" , cl::init(false) , cl::Hidden ) static