diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2024-01-05 14:08:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-05 14:08:53 +0000 |
commit | a776740d6296520b8bde156aa3f8d9ecb32cddd9 (patch) | |
tree | 784b4647ec1c2b2d8e2a3e665c25f7d200eda5f9 /llvm/lib/IR | |
parent | 2b88bd110cbe61e1e3ef764d0362a75dc7c9cd50 (diff) | |
download | llvm-a776740d6296520b8bde156aa3f8d9ecb32cddd9.zip llvm-a776740d6296520b8bde156aa3f8d9ecb32cddd9.tar.gz llvm-a776740d6296520b8bde156aa3f8d9ecb32cddd9.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 95cdec7..278cdfc 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)) |