[llvm] fa77e1f - [DebugInfo][RemoveDIs] Convert back to intrinsic form for ThinLTO

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 13:24:37 PST 2024


Author: Jeremy Morse
Date: 2024-02-13T21:24:04Z
New Revision: fa77e1f5468bc6be99da89860f42059df13d3b82

URL: https://github.com/llvm/llvm-project/commit/fa77e1f5468bc6be99da89860f42059df13d3b82
DIFF: https://github.com/llvm/llvm-project/commit/fa77e1f5468bc6be99da89860f42059df13d3b82.diff

LOG: [DebugInfo][RemoveDIs] Convert back to intrinsic form for ThinLTO

As explained on discourse [0] (comment 12), to get the non-intrinsic form
of debug-info records enabled and testing, we're only using it inside of
the pass manager in LLVM right now. Things like the textual IR writer and
bitcode writing _passes_ are instrumented to convert back to
intrinsic-form when writing a module out, but it turns out we missed the
ThinLTO bitcode writing pass. That causes uh, all variable location
debug-info to be dropped in ThinLTO mode (oops).

This patch adds that conversion; it should be low risk as it's identical to
what happens in all the other passes. However should this commit turn out
to cause trouble, please instead revert d759618df76 or whichever is the
most recent commit to set UseNewDbgInfoFormat to default to true. That'll
revert LLVM back to the definitely-correct behaviour.

[0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index e5f9fa1dda88e3..dd6062d303d42e 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -580,11 +580,22 @@ PreservedAnalyses
 llvm::ThinLTOBitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
   FunctionAnalysisManager &FAM =
       AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
+
+  // RemoveDIs: there's no bitcode representation of the DPValue debug-info,
+  // convert to dbg.values before writing out.
+  bool IsNewDbgInfoFormat = M.IsNewDbgInfoFormat;
+  if (IsNewDbgInfoFormat)
+    M.convertFromNewDbgValues();
+
   bool Changed = writeThinLTOBitcode(
       OS, ThinLinkOS,
       [&FAM](Function &F) -> AAResults & {
         return FAM.getResult<AAManager>(F);
       },
       M, &AM.getResult<ModuleSummaryIndexAnalysis>(M));
+
+  if (IsNewDbgInfoFormat)
+    M.convertToNewDbgValues();
+
   return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
 }


        


More information about the llvm-commits mailing list