-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DebugInfo] Correctly track metadata slots for DPValues #76941
Conversation
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.
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-debuginfo Author: Stephen Tozer (SLTozer) ChangesCurrently, 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. Full diff: https://github.com/llvm/llvm-project/pull/76941.diff 1 Files Affected:
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 95cdec722062e3..278cdfce411050 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -859,6 +859,9 @@ class SlotTracker : public AbstractSlotTrackerStorage {
/// 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))
|
IIRC there's a reproducer somewhere that stimulates this, would we be able to add that as a regression test? Otherwise LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right, #76952 stimulates the change, I see. LGTM.
The change is fairly mechanical: 1. Factor code from `FastISel::selectIntrinsicCall`, which converts debug intrinsics into debug instructions, into functions (NFC). 2. Call those functions for DPValues attached to instructions too. The test updates look the same as other RemoveDIs changes: re-run the tests with `--try-experimental-debuginfo-iterators`, which checks the output is identical using the new debug info format (if it has been enabled in the cmake configuration). Depends on #76941 (otherwise some modified tests spuriously fail).
In line with other RemoveDIs test updates. This test fails without #76941.
In line with other RemoveDIs test updates. This test fails without llvm#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.