Skip to content

Commit fa77e1f

Browse files
committed
[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 d759618 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
1 parent 91f4a84 commit fa77e1f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,22 @@ PreservedAnalyses
580580
llvm::ThinLTOBitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
581581
FunctionAnalysisManager &FAM =
582582
AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
583+
584+
// RemoveDIs: there's no bitcode representation of the DPValue debug-info,
585+
// convert to dbg.values before writing out.
586+
bool IsNewDbgInfoFormat = M.IsNewDbgInfoFormat;
587+
if (IsNewDbgInfoFormat)
588+
M.convertFromNewDbgValues();
589+
583590
bool Changed = writeThinLTOBitcode(
584591
OS, ThinLinkOS,
585592
[&FAM](Function &F) -> AAResults & {
586593
return FAM.getResult<AAManager>(F);
587594
},
588595
M, &AM.getResult<ModuleSummaryIndexAnalysis>(M));
596+
597+
if (IsNewDbgInfoFormat)
598+
M.convertToNewDbgValues();
599+
589600
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
590601
}

0 commit comments

Comments
 (0)