LLVM 24.0.0git
LiveDebugVariables.cpp File Reference
#include "llvm/CodeGen/LiveDebugVariables.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntervalMap.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/LexicalScopes.h"
#include "llvm/CodeGen/LiveInterval.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachinePassManager.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/VirtRegMap.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Function.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <map>
#include <memory>
#include <optional>
#include <utility>

Go to the source code of this file.

Classes

struct  InsertLocCache
 Caches used by findInsertLocation so that repeated insertions at the same position don't rescan the debug instructions already inserted there. More...
class  llvm::LiveDebugVariables::LDVImpl

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.

Macros

#define DEBUG_TYPE   "livedebugvars"

Typedefs

using LocMap = IntervalMap<SlotIndex, DbgVariableValue, 4>
 Map of where a user value is live to that value.
using SpillOffsetMap = DenseMap<unsigned, unsigned>
 Map of stack slot offsets for spilled locations.

Enumerations

enum  : unsigned { UndefLocNo = ~0U }

Functions

 STATISTIC (NumInsertedDebugValues, "Number of DBG_VALUEs inserted")
 STATISTIC (NumInsertedDebugLabels, "Number of DBG_LABELs inserted")
 STATISTIC (NumStaleIndexes, "Number of stale SlotIndexes repaired")
 STATISTIC (NumMergedIntervals, "Number of debug value intervals merged while repairing indexes")
 INITIALIZE_PASS_BEGIN (LiveDebugVariablesWrapperLegacy, DEBUG_TYPE, "Debug Variable Analysis", false, false) INITIALIZE_PASS_END(LiveDebugVariablesWrapperLegacy
static void printDebugLoc (const DebugLoc &DL, raw_ostream &CommentOS, const LLVMContext &Ctx)
static void printExtendedName (raw_ostream &OS, const DINode *Node, const DILocation *DL)
static void removeDebugInstrs (MachineFunction &mf)
static MachineBasicBlock::iterator findInsertLocation (MachineBasicBlock *MBB, SlotIndex Idx, LiveIntervals &LIS, InsertLocCache &Cache)
 Find an iterator for inserting a DBG_VALUE instruction.
static MachineBasicBlock::iterator findNextInsertLocation (MachineBasicBlock *MBB, MachineBasicBlock::iterator I, SlotIndex StopIdx, ArrayRef< MachineOperand > LocMOs, LiveIntervals &LIS, const TargetRegisterInfo &TRI)
 Find an iterator for inserting the next DBG_VALUE instruction (or end if no more insert locations found).

Variables

static cl::opt< bool > EnableLDV ("live-debug-variables", cl::init(true), cl::desc("Enable the live debug variables pass"), cl::Hidden)
 DEBUG_TYPE
Debug Variable Analysis
Debug Variable false

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "livedebugvars"

Definition at line 68 of file LiveDebugVariables.cpp.

Typedef Documentation

◆ LocMap

using LocMap = IntervalMap<SlotIndex, DbgVariableValue, 4>

Map of where a user value is live to that value.

Definition at line 262 of file LiveDebugVariables.cpp.

◆ SpillOffsetMap

Map of stack slot offsets for spilled locations.

Non-spilled locations are not added to the map.

Definition at line 266 of file LiveDebugVariables.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : unsigned
Enumerator
UndefLocNo 

Definition at line 98 of file LiveDebugVariables.cpp.

Function Documentation

◆ findInsertLocation()

MachineBasicBlock::iterator findInsertLocation ( MachineBasicBlock * MBB,
SlotIndex Idx,
LiveIntervals & LIS,
InsertLocCache & Cache )
static

◆ findNextInsertLocation()

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LiveDebugVariablesWrapperLegacy ,
DEBUG_TYPE ,
"Debug Variable Analysis" ,
false ,
false  )

◆ printDebugLoc()

void printDebugLoc ( const DebugLoc & DL,
raw_ostream & CommentOS,
const LLVMContext & Ctx )
static

Definition at line 708 of file LiveDebugVariables.cpp.

References llvm::cast(), DL, and printDebugLoc().

Referenced by printDebugLoc(), and printExtendedName().

◆ printExtendedName()

void printExtendedName ( raw_ostream & OS,
const DINode * Node,
const DILocation * DL )
static

◆ removeDebugInstrs()

void removeDebugInstrs ( MachineFunction & mf)
static

Definition at line 1324 of file LiveDebugVariables.cpp.

References llvm::make_early_inc_range(), MBB, and MI.

Referenced by llvm::LiveDebugVariables::analyze().

◆ STATISTIC() [1/4]

STATISTIC ( NumInsertedDebugLabels ,
"Number of DBG_LABELs inserted"  )

◆ STATISTIC() [2/4]

STATISTIC ( NumInsertedDebugValues ,
"Number of DBG_VALUEs inserted"  )

◆ STATISTIC() [3/4]

STATISTIC ( NumMergedIntervals ,
"Number of debug value intervals merged while repairing indexes"  )

◆ STATISTIC() [4/4]

STATISTIC ( NumStaleIndexes ,
"Number of stale SlotIndexes repaired"  )

Variable Documentation

◆ Analysis

Debug Variable Analysis

Definition at line 86 of file LiveDebugVariables.cpp.

◆ DEBUG_TYPE

DEBUG_TYPE

Definition at line 85 of file LiveDebugVariables.cpp.

◆ EnableLDV

cl::opt< bool > EnableLDV("live-debug-variables", cl::init(true), cl::desc("Enable the live debug variables pass"), cl::Hidden) ( "live-debug-variables" ,
cl::init(true) ,
cl::desc("Enable the live debug variables pass") ,
cl::Hidden  )
static

◆ false

Debug Variable false

Definition at line 86 of file LiveDebugVariables.cpp.