From 8e45935824a905dec7739ea8c95af5fdf2c0c123 Mon Sep 17 00:00:00 2001 From: Stephen Tozer Date: Mon, 22 Apr 2024 13:37:06 +0100 Subject: [RemoveDIs] Make verify-uselistorder preserve the input debug info format (#87789) Verify-uselistorder wants to take some input IR and verify that the uselist order is stable after roundtripping to bitcode and assembly. This is disrupted if the file is converted between the new and old debug info formats after parsing - while there's no functional difference, the change to the in-memory representation of the IR modifies the uselist. This patch changes verify-uselistorder to not convert input files between debug info formats by default, preventing changes from being made to the file being checked. In addition, this patch makes it so that when we _do_ print IR in the new debug info format to bitcode or assembly, we delete any lingering debug intrinsic declarations, ensuring that we don't write uselist entries for them. --- llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp index 4f2486c963e9..5f66e1ea0a83 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp @@ -23,6 +23,8 @@ extern bool WriteNewDbgInfoFormatToBitcode; PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) { ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat && WriteNewDbgInfoFormatToBitcode); + if (M.IsNewDbgInfoFormat) + M.removeDebugIntrinsicDeclarations(); const ModuleSummaryIndex *Index = EmitSummaryIndex ? &(AM.getResult(M)) @@ -54,6 +56,8 @@ namespace { bool runOnModule(Module &M) override { ScopedDbgInfoFormatSetter FormatSetter( M, M.IsNewDbgInfoFormat && WriteNewDbgInfoFormatToBitcode); + if (M.IsNewDbgInfoFormat) + M.removeDebugIntrinsicDeclarations(); WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, /*Index=*/nullptr, /*EmitModuleHash=*/false); -- cgit v1.2.3