Anonymous View
LLVM 23.0.0git
BTFDebug.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "btf-debug"
#define GET_CC_REGISTER_LISTS
#define HANDLE_BTF_KIND(ID, NAME)

Functions

static const DITypetryRemoveAtomicType (const DIType *Ty)
static const DITypestripDITypeAttributes (const DIType *Ty)
static bool sourceArgMatchesIRType (const DIType *SourceTy, Type *IRTy)
static SmallVector< std::pair< uint32_t, Register >, 8 > collectNocallEntryArgRegs (const MachineFunction &MF)
 Collect the physical register each source argument lives in by scanning DBG_VALUE instructions in the entry block.
static bool canUseNocallOptimizedSignature (const MachineFunction &MF, DITypeArray Elements, ArrayRef< std::pair< uint32_t, Register > > AliveArgs, const TargetRegisterInfo &TRI)
 Check whether the optimized IR signature matches the surviving source arguments precisely enough to emit a filtered BTF prototype.

Variables

static const charBTFKindStr []

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "btf-debug"

Definition at line 40 of file BTFDebug.cpp.

◆ GET_CC_REGISTER_LISTS

#define GET_CC_REGISTER_LISTS

Definition at line 42 of file BTFDebug.cpp.

◆ HANDLE_BTF_KIND

#define HANDLE_BTF_KIND ( ID,
NAME )
Value:
"BTF_KIND_" #NAME,

Function Documentation

◆ canUseNocallOptimizedSignature()

bool canUseNocallOptimizedSignature ( const MachineFunction & MF,
DITypeArray Elements,
ArrayRef< std::pair< uint32_t, Register > > AliveArgs,
const TargetRegisterInfo & TRI )
static

Check whether the optimized IR signature matches the surviving source arguments precisely enough to emit a filtered BTF prototype.

Requires exact IR/source arg count match, matching types, and correct BPF register order (R1..R5) for register args.

Definition at line 216 of file BTFDebug.cpp.

References llvm::Function::arg_begin(), llvm::Function::arg_size(), llvm::dbgs(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getName(), I, LLVM_DEBUG, N, Reg, sourceArgMatchesIRType(), and TRI.

Referenced by llvm::BTFDebug::beginFunctionImpl().

◆ collectNocallEntryArgRegs()

SmallVector< std::pair< uint32_t, Register >, 8 > collectNocallEntryArgRegs ( const MachineFunction & MF)
static

Collect the physical register each source argument lives in by scanning DBG_VALUE instructions in the entry block.

A DBG_VALUE is only recorded when its register either (a) has not been redefined by any preceding non-debug instruction (i.e. it still holds the caller-passed value), or (b) was most recently loaded from the stack via $r11 (a stack-passed argument beyond the first five register args).

There is another case where DBG_VALUE is not emitted due to AssignmentTrackingAnalysis which determines that a variable is always stack-homed, and describes the variable via MachineFunction's VariableDbgInfo (setVariableDbgInfo with a frame index). To recover the register for those arguments, we also track stores of un-redefined physical registers to stack frame objects during the entry-block walk (using MachineMemOperands to identify the target frame index), then match them against VariableDbgInfo entries after the scan.

Definition at line 123 of file BTFDebug.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::begin(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::contains(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineFunction::front(), llvm::DILocalVariable::getArg(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::MachineFrameInfo::getObjectAllocation(), llvm::MachineFrameInfo::getObjectIndexEnd(), llvm::MachineOperand::getReg(), llvm::DILocalVariable::getScope(), llvm::DILocalScope::getSubprogram(), llvm::Function::getSubprogram(), llvm::MachineFunction::getVariableDbgInfo(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::Register::isPhysical(), llvm::MachineOperand::isReg(), MI, N, llvm::sort(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace().

Referenced by llvm::BTFDebug::beginFunctionImpl().

◆ sourceArgMatchesIRType()

◆ stripDITypeAttributes()

const DIType * stripDITypeAttributes ( const DIType * Ty)
static

Definition at line 59 of file BTFDebug.cpp.

References llvm::dyn_cast_or_null().

Referenced by sourceArgMatchesIRType().

◆ tryRemoveAtomicType()

Variable Documentation

◆ BTFKindStr

const char* BTFKindStr[]
static
Initial value:
= {
#define HANDLE_BTF_KIND(ID, NAME)
}

Definition at line 45 of file BTFDebug.cpp.

Referenced by llvm::BTFTypeBase::emitType().