summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2024-01-05 14:08:53 +0000
committerGitHub <noreply@github.com>2024-01-05 14:08:53 +0000
commita776740d6296520b8bde156aa3f8d9ecb32cddd9 (patch)
tree784b4647ec1c2b2d8e2a3e665c25f7d200eda5f9
parent2b88bd110cbe61e1e3ef764d0362a75dc7c9cd50 (diff)
[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.
-rw-r--r--llvm/lib/IR/AsmWriter.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 95cdec722062..278cdfce4110 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -859,6 +859,9 @@ private:
/// Add all of the metadata from an instruction.
void processInstructionMetadata(const Instruction &I);
+
+ /// Add all of the metadata from an instruction.
+ void processDPValueMetadata(const DPValue &DPV);
};
} // end namespace llvm
@@ -1126,11 +1129,19 @@ void SlotTracker::processGlobalObjectMetadata(const GlobalObject &GO) {
void SlotTracker::processFunctionMetadata(const Function &F) {
processGlobalObjectMetadata(F);
for (auto &BB : F) {
- for (auto &I : BB)
+ for (auto &I : BB) {
+ for (const DPValue &DPV : I.getDbgValueRange())
+ processDPValueMetadata(DPV);
processInstructionMetadata(I);
+ }
}
}
+void SlotTracker::processDPValueMetadata(const DPValue &DPV) {
+ CreateMetadataSlot(DPV.getVariable());
+ CreateMetadataSlot(DPV.getDebugLoc());
+}
+
void SlotTracker::processInstructionMetadata(const Instruction &I) {
// Process metadata used directly by intrinsics.
if (const CallInst *CI = dyn_cast<CallInst>(&I))