From 9ee8d2e081d2622b31e57154458b0317e437d98f Mon Sep 17 00:00:00 2001 From: Anton Sidorenko Date: Mon, 21 Nov 2022 15:26:27 +0300 Subject: [PATCH] [Debugify] Strip llvm.mir.debugify metadata 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. Differential Revision: https://reviews.llvm.org/D138417 --- llvm/lib/Transforms/Utils/Debugify.cpp | 7 ++++++- llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp index f17d252..74ead37 100644 --- a/llvm/lib/Transforms/Utils/Debugify.cpp +++ b/llvm/lib/Transforms/Utils/Debugify.cpp @@ -243,13 +243,18 @@ applyDebugify(Module &M, 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); diff --git a/llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir b/llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir index 08f35c0..59dcff9 100644 --- a/llvm/test/CodeGen/Generic/MIRDebugify/locations-and-values.mir +++ b/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 ... --- -- 2.7.4