Skip to content

Commit a776740

Browse files
authored
[DebugInfo] Correctly track metadata slots for DPValues (#76941)
Currently, the AsmWriter can print DPValues, but does not consider them when creating slots for metadata, which can result in erroneous output where metadata is numbered incorrectly. This patch modifies the ModuleSlotTracker to correctly track slots for metadata that appears in DPValues.
1 parent 2b88bd1 commit a776740

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

llvm/lib/IR/AsmWriter.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,9 @@ class SlotTracker : public AbstractSlotTrackerStorage {
859859

860860
/// Add all of the metadata from an instruction.
861861
void processInstructionMetadata(const Instruction &I);
862+
863+
/// Add all of the metadata from an instruction.
864+
void processDPValueMetadata(const DPValue &DPV);
862865
};
863866

864867
} // end namespace llvm
@@ -1126,11 +1129,19 @@ void SlotTracker::processGlobalObjectMetadata(const GlobalObject &GO) {
11261129
void SlotTracker::processFunctionMetadata(const Function &F) {
11271130
processGlobalObjectMetadata(F);
11281131
for (auto &BB : F) {
1129-
for (auto &I : BB)
1132+
for (auto &I : BB) {
1133+
for (const DPValue &DPV : I.getDbgValueRange())
1134+
processDPValueMetadata(DPV);
11301135
processInstructionMetadata(I);
1136+
}
11311137
}
11321138
}
11331139

1140+
void SlotTracker::processDPValueMetadata(const DPValue &DPV) {
1141+
CreateMetadataSlot(DPV.getVariable());
1142+
CreateMetadataSlot(DPV.getDebugLoc());
1143+
}
1144+
11341145
void SlotTracker::processInstructionMetadata(const Instruction &I) {
11351146
// Process metadata used directly by intrinsics.
11361147
if (const CallInst *CI = dyn_cast<CallInst>(&I))

0 commit comments

Comments
 (0)