aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp122
1 files changed, 64 insertions, 58 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 1736961..09bce9d 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -63,7 +63,7 @@ TinyPtrVector<DbgDeclareInst *> llvm::findDbgDeclares(Value *V) {
return Declares;
}
-TinyPtrVector<DPValue *> llvm::findDPVDeclares(Value *V) {
+TinyPtrVector<DbgVariableRecord *> llvm::findDVRDeclares(Value *V) {
// This function is hot. Check whether the value has any metadata to avoid a
// DenseMap lookup.
if (!V->isUsedByMetadata())
@@ -72,18 +72,19 @@ TinyPtrVector<DPValue *> llvm::findDPVDeclares(Value *V) {
if (!L)
return {};
- TinyPtrVector<DPValue *> Declares;
- for (DPValue *DPV : L->getAllDPValueUsers())
- if (DPV->getType() == DPValue::LocationType::Declare)
- Declares.push_back(DPV);
+ TinyPtrVector<DbgVariableRecord *> Declares;
+ for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers())
+ if (DVR->getType() == DbgVariableRecord::LocationType::Declare)
+ Declares.push_back(DVR);
return Declares;
}
-template <typename IntrinsicT,
- DPValue::LocationType Type = DPValue::LocationType::Any>
-static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
- SmallVectorImpl<DPValue *> *DPValues) {
+template <typename IntrinsicT, DbgVariableRecord::LocationType Type =
+ DbgVariableRecord::LocationType::Any>
+static void
+findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
+ SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
// This function is hot. Check whether the value has any metadata to avoid a
// DenseMap lookup.
if (!V->isUsedByMetadata())
@@ -96,25 +97,27 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
// V will also appear twice in a dbg.assign if its used in the both the value
// and address components.
SmallPtrSet<IntrinsicT *, 4> EncounteredIntrinsics;
- SmallPtrSet<DPValue *, 4> EncounteredDPValues;
+ SmallPtrSet<DbgVariableRecord *, 4> EncounteredDbgVariableRecords;
/// Append IntrinsicT users of MetadataAsValue(MD).
- auto AppendUsers = [&Ctx, &EncounteredIntrinsics, &EncounteredDPValues,
- &Result, DPValues](Metadata *MD) {
+ auto AppendUsers = [&Ctx, &EncounteredIntrinsics,
+ &EncounteredDbgVariableRecords, &Result,
+ DbgVariableRecords](Metadata *MD) {
if (auto *MDV = MetadataAsValue::getIfExists(Ctx, MD)) {
for (User *U : MDV->users())
if (IntrinsicT *DVI = dyn_cast<IntrinsicT>(U))
if (EncounteredIntrinsics.insert(DVI).second)
Result.push_back(DVI);
}
- if (!DPValues)
+ if (!DbgVariableRecords)
return;
- // Get DPValues that use this as a single value.
+ // Get DbgVariableRecords that use this as a single value.
if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
- for (DPValue *DPV : L->getAllDPValueUsers()) {
- if (Type == DPValue::LocationType::Any || DPV->getType() == Type)
- if (EncounteredDPValues.insert(DPV).second)
- DPValues->push_back(DPV);
+ for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers()) {
+ if (Type == DbgVariableRecord::LocationType::Any ||
+ DVR->getType() == Type)
+ if (EncounteredDbgVariableRecords.insert(DVR).second)
+ DbgVariableRecords->push_back(DVR);
}
}
};
@@ -123,27 +126,30 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
AppendUsers(L);
for (Metadata *AL : L->getAllArgListUsers()) {
AppendUsers(AL);
- if (!DPValues)
+ if (!DbgVariableRecords)
continue;
DIArgList *DI = cast<DIArgList>(AL);
- for (DPValue *DPV : DI->getAllDPValueUsers())
- if (Type == DPValue::LocationType::Any || DPV->getType() == Type)
- if (EncounteredDPValues.insert(DPV).second)
- DPValues->push_back(DPV);
+ for (DbgVariableRecord *DVR : DI->getAllDbgVariableRecordUsers())
+ if (Type == DbgVariableRecord::LocationType::Any ||
+ DVR->getType() == Type)
+ if (EncounteredDbgVariableRecords.insert(DVR).second)
+ DbgVariableRecords->push_back(DVR);
}
}
}
-void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues,
- Value *V, SmallVectorImpl<DPValue *> *DPValues) {
- findDbgIntrinsics<DbgValueInst, DPValue::LocationType::Value>(DbgValues, V,
- DPValues);
+void llvm::findDbgValues(
+ SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V,
+ SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
+ findDbgIntrinsics<DbgValueInst, DbgVariableRecord::LocationType::Value>(
+ DbgValues, V, DbgVariableRecords);
}
-void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,
- Value *V, SmallVectorImpl<DPValue *> *DPValues) {
- findDbgIntrinsics<DbgVariableIntrinsic, DPValue::LocationType::Any>(
- DbgUsers, V, DPValues);
+void llvm::findDbgUsers(
+ SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers, Value *V,
+ SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
+ findDbgIntrinsics<DbgVariableIntrinsic, DbgVariableRecord::LocationType::Any>(
+ DbgUsers, V, DbgVariableRecords);
}
DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {
@@ -164,16 +170,16 @@ DebugLoc llvm::getDebugValueLoc(DbgVariableIntrinsic *DII) {
return DILocation::get(DII->getContext(), 0, 0, Scope, InlinedAt);
}
-DebugLoc llvm::getDebugValueLoc(DPValue *DPV) {
+DebugLoc llvm::getDebugValueLoc(DbgVariableRecord *DVR) {
// Original dbg.declare must have a location.
- const DebugLoc &DeclareLoc = DPV->getDebugLoc();
+ const DebugLoc &DeclareLoc = DVR->getDebugLoc();
MDNode *Scope = DeclareLoc.getScope();
DILocation *InlinedAt = DeclareLoc.getInlinedAt();
// Because no machine insts can come from debug intrinsics, only the scope
// and inlinedAt is significant. Zero line numbers are used in case this
// DebugLoc leaks into any adjacent instructions. Produce an unknown location
// with the correct scope / inlinedAt fields.
- return DILocation::get(DPV->getContext(), 0, 0, Scope, InlinedAt);
+ return DILocation::get(DVR->getContext(), 0, 0, Scope, InlinedAt);
}
//===----------------------------------------------------------------------===//
@@ -253,8 +259,8 @@ void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) {
}
void DebugInfoFinder::processDbgRecord(const Module &M, const DbgRecord &DR) {
- if (const DPValue *DPV = dyn_cast<const DPValue>(&DR))
- processVariable(M, DPV->getVariable());
+ if (const DbgVariableRecord *DVR = dyn_cast<const DbgVariableRecord>(&DR))
+ processVariable(M, DVR->getVariable());
processLocation(M, DR.getDebugLoc().get());
}
@@ -1864,14 +1870,14 @@ AssignmentMarkerRange at::getAssignmentMarkers(DIAssignID *ID) {
void at::deleteAssignmentMarkers(const Instruction *Inst) {
auto Range = getAssignmentMarkers(Inst);
- SmallVector<DPValue *> DPVAssigns = getDPVAssignmentMarkers(Inst);
- if (Range.empty() && DPVAssigns.empty())
+ SmallVector<DbgVariableRecord *> DVRAssigns = getDVRAssignmentMarkers(Inst);
+ if (Range.empty() && DVRAssigns.empty())
return;
SmallVector<DbgAssignIntrinsic *> ToDelete(Range.begin(), Range.end());
for (auto *DAI : ToDelete)
DAI->eraseFromParent();
- for (auto *DPV : DPVAssigns)
- DPV->eraseFromParent();
+ for (auto *DVR : DVRAssigns)
+ DVR->eraseFromParent();
}
void at::RAUW(DIAssignID *Old, DIAssignID *New) {
@@ -1889,12 +1895,12 @@ void at::RAUW(DIAssignID *Old, DIAssignID *New) {
void at::deleteAll(Function *F) {
SmallVector<DbgAssignIntrinsic *, 12> ToDelete;
- SmallVector<DPValue *, 12> DPToDelete;
+ SmallVector<DbgVariableRecord *, 12> DPToDelete;
for (BasicBlock &BB : *F) {
for (Instruction &I : BB) {
- for (DPValue &DPV : filterDbgVars(I.getDbgRecordRange()))
- if (DPV.isDbgAssign())
- DPToDelete.push_back(&DPV);
+ for (DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange()))
+ if (DVR.isDbgAssign())
+ DPToDelete.push_back(&DVR);
if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(&I))
ToDelete.push_back(DAI);
else
@@ -1903,20 +1909,20 @@ void at::deleteAll(Function *F) {
}
for (auto *DAI : ToDelete)
DAI->eraseFromParent();
- for (auto *DPV : DPToDelete)
- DPV->eraseFromParent();
+ for (auto *DVR : DPToDelete)
+ DVR->eraseFromParent();
}
/// Get the FragmentInfo for the variable if it exists, otherwise return a
/// FragmentInfo that covers the entire variable if the variable size is
/// known, otherwise return a zero-sized fragment.
static DIExpression::FragmentInfo
-getFragmentOrEntireVariable(const DPValue *DPV) {
+getFragmentOrEntireVariable(const DbgVariableRecord *DVR) {
DIExpression::FragmentInfo VariableSlice(0, 0);
// Get the fragment or variable size, or zero.
- if (auto Sz = DPV->getFragmentSizeInBits())
+ if (auto Sz = DVR->getFragmentSizeInBits())
VariableSlice.SizeInBits = *Sz;
- if (auto Frag = DPV->getExpression()->getFragmentInfo())
+ if (auto Frag = DVR->getExpression()->getFragmentInfo())
VariableSlice.OffsetInBits = Frag->OffsetInBits;
return VariableSlice;
}
@@ -2080,10 +2086,10 @@ bool at::calculateFragmentIntersect(
}
bool at::calculateFragmentIntersect(
const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits,
- uint64_t SliceSizeInBits, const DPValue *DPVAssign,
+ uint64_t SliceSizeInBits, const DbgVariableRecord *DVRAssign,
std::optional<DIExpression::FragmentInfo> &Result) {
return calculateFragmentIntersectImpl(DL, Dest, SliceOffsetInBits,
- SliceSizeInBits, DPVAssign, Result);
+ SliceSizeInBits, DVRAssign, Result);
}
/// Collect constant properies (base, size, offset) of \p StoreDest.
@@ -2177,7 +2183,7 @@ static void emitDbgAssign(AssignmentInfo Info, Value *Val, Value *Dest,
DIExpression *AddrExpr =
DIExpression::get(StoreLikeInst.getContext(), std::nullopt);
if (StoreLikeInst.getParent()->IsNewDbgInfoFormat) {
- auto *Assign = DPValue::createLinkedDPVAssign(
+ auto *Assign = DbgVariableRecord::createLinkedDVRAssign(
&StoreLikeInst, Val, VarRec.Var, Expr, Dest, AddrExpr, VarRec.DL);
(void)Assign;
LLVM_DEBUG(if (Assign) errs() << " > INSERT: " << *Assign << "\n");
@@ -2295,7 +2301,7 @@ bool AssignmentTrackingPass::runOnFunction(Function &F) {
// storage" is limited to Allocas). We'll use this to find dbg.declares to
// delete after running `trackAssignments`.
DenseMap<const AllocaInst *, SmallPtrSet<DbgDeclareInst *, 2>> DbgDeclares;
- DenseMap<const AllocaInst *, SmallPtrSet<DPValue *, 2>> DPVDeclares;
+ DenseMap<const AllocaInst *, SmallPtrSet<DbgVariableRecord *, 2>> DVRDeclares;
// Create another similar map of {storage : variables} that we'll pass to
// trackAssignments.
StorageToVarsMap Vars;
@@ -2321,9 +2327,9 @@ bool AssignmentTrackingPass::runOnFunction(Function &F) {
};
for (auto &BB : F) {
for (auto &I : BB) {
- for (DPValue &DPV : filterDbgVars(I.getDbgRecordRange())) {
- if (DPV.isDbgDeclare())
- ProcessDeclare(&DPV, DPVDeclares);
+ for (DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange())) {
+ if (DVR.isDbgDeclare())
+ ProcessDeclare(&DVR, DVRDeclares);
}
if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(&I))
ProcessDeclare(DDI, DbgDeclares);
@@ -2364,8 +2370,8 @@ bool AssignmentTrackingPass::runOnFunction(Function &F) {
};
for (auto &P : DbgDeclares)
DeleteSubsumedDeclare(at::getAssignmentMarkers(P.first), P.second);
- for (auto &P : DPVDeclares)
- DeleteSubsumedDeclare(at::getDPVAssignmentMarkers(P.first), P.second);
+ for (auto &P : DVRDeclares)
+ DeleteSubsumedDeclare(at::getDVRAssignmentMarkers(P.first), P.second);
return Changed;
}