[PATCH] D138417: [Debugify] Strip llvm.mir.debugify metadata

Anton Sidorenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 04:35:58 PST 2022


asi-sc created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
asi-sc requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We don't strip llvm.mir.debugify metadata in `llvm::stripDebugifyMetadata`. This
may lead to incorrect number of lines and variables in the metadata when we run
debugify twice, e.g. -run-pass=mir-debugify,...,mir-strip-debug,...,mir-debugify.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138417

Files:
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir


Index: llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir
===================================================================
--- llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir
+++ llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir
@@ -27,7 +27,7 @@
   ; VALUE: [[VAR1:![0-9]+]] = !DILocalVariable(name: "1"
   ; VALUE: [[VAR2:![0-9]+]] = !DILocalVariable(name: "2"
   ; STRIP-NOT: !llvm.debugify
-  ; STRIP: !llvm.mir.debugify
+  ; STRIP-NOT: !llvm.mir.debugify
 
 ...
 ---
Index: llvm/lib/Transforms/Utils/Debugify.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Debugify.cpp
+++ llvm/lib/Transforms/Utils/Debugify.cpp
@@ -243,13 +243,18 @@
 bool llvm::stripDebugifyMetadata(Module &M) {
   bool Changed = false;
 
-  // Remove the llvm.debugify module-level named metadata.
+  // Remove the llvm.debugify and llvm.mir.debugify module-level named metadata.
   NamedMDNode *DebugifyMD = M.getNamedMetadata("llvm.debugify");
   if (DebugifyMD) {
     M.eraseNamedMetadata(DebugifyMD);
     Changed = true;
   }
 
+  if (auto *MIRDebugifyMD = M.getNamedMetadata("llvm.mir.debugify")) {
+    M.eraseNamedMetadata(MIRDebugifyMD);
+    Changed = true;
+  }
+
   // Strip out all debug intrinsics and supporting metadata (subprograms, types,
   // variables, etc).
   Changed |= StripDebugInfo(M);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138417.476859.patch
Type: text/x-patch
Size: 1387 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221121/5490080e/attachment.bin>


More information about the llvm-commits mailing list