[llvm] [RemoveDIs] Do not load into new debug info format from bitcode by default (PR #86268)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 02:27:55 PDT 2024


https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/86268

>From 7929af8768b42721557ff30dec8c47434d9ef732 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Fri, 22 Mar 2024 10:32:24 +0000
Subject: [PATCH 1/3] [RemoveDIs] Do not load into new debug info format from
 bitcode by default

This is NFC right now, as the default behaviour is "do not load into the
new debug info format by default", but we want to change that soon.

Additionally unconditionally convert from the new debug info format into if
we've loaded into it (e.g., if the bitcode file loaded was already in the new
format).

The latter change is needed because verify-uselistorder doesn't yet understand
DbgRecords (it doesn't know how to map them).

The former change is needed because if we load from an old debug format bitcode
file but load directly into the new format _and then convert back to the old
mode after_, the use-lists of the debug intrinsic functions (the functions'
global value uses) change.
---
 .../tools/verify-uselistorder/verify-uselistorder.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
index d929ae09958a1f..e6ba715ace7838 100644
--- a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -68,6 +68,7 @@ static cl::opt<unsigned>
                 cl::desc("Number of times to shuffle and verify use-lists"),
                 cl::init(1), cl::cat(Cat));
 
+extern cl::opt<cl::boolOrDefault> LoadBitcodeIntoNewDbgInforFormat;
 namespace {
 
 struct TempFile {
@@ -169,8 +170,7 @@ std::unique_ptr<Module> TempFile::readBitcode(LLVMContext &Context) const {
 
   // verify-uselistoder currently only supports old-style debug info mode.
   // FIXME: Update mapping code for RemoveDIs.
-  assert(!ModuleOr.get()->IsNewDbgInfoFormat &&
-         "Unexpectedly in new debug info mode");
+  ModuleOr.get()->setIsNewDbgInfoFormat(false);
   return std::move(ModuleOr.get());
 }
 
@@ -182,7 +182,7 @@ std::unique_ptr<Module> TempFile::readAssembly(LLVMContext &Context) const {
     Err.print("verify-uselistorder", errs());
   // verify-uselistoder currently only supports old-style debug info mode.
   // FIXME: Update mapping code for RemoveDIs.
-  assert(!M->IsNewDbgInfoFormat && "Unexpectedly in new debug info mode");
+  M->setIsNewDbgInfoFormat(false);
   return M;
 }
 
@@ -543,6 +543,9 @@ int main(int argc, char **argv) {
   cl::HideUnrelatedOptions(Cat);
   cl::ParseCommandLineOptions(argc, argv,
                               "llvm tool to verify use-list order\n");
+  // Do not load bitcode into the new debug info format by default.
+  if (LoadBitcodeIntoNewDbgInforFormat == cl::boolOrDefault::BOU_UNSET)
+    LoadBitcodeIntoNewDbgInforFormat = cl::boolOrDefault::BOU_FALSE;
 
   LLVMContext Context;
   SMDiagnostic Err;
@@ -551,7 +554,7 @@ int main(int argc, char **argv) {
   std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
   // verify-uselistoder currently only supports old-style debug info mode.
   // FIXME: Update mapping code for RemoveDIs.
-  assert(!M->IsNewDbgInfoFormat && "Unexpectedly in new debug info mode");
+  M->setIsNewDbgInfoFormat(false);
 
   if (!M.get()) {
     Err.print(argv[0], errs());

>From 7286e6fb8093d7d8e79cc57b842cd0786f16d8fc Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Mon, 25 Mar 2024 09:27:09 +0000
Subject: [PATCH 2/3] whitespace

---
 llvm/tools/verify-uselistorder/verify-uselistorder.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
index e6ba715ace7838..8ad24e40b8d980 100644
--- a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -543,6 +543,7 @@ int main(int argc, char **argv) {
   cl::HideUnrelatedOptions(Cat);
   cl::ParseCommandLineOptions(argc, argv,
                               "llvm tool to verify use-list order\n");
+
   // Do not load bitcode into the new debug info format by default.
   if (LoadBitcodeIntoNewDbgInforFormat == cl::boolOrDefault::BOU_UNSET)
     LoadBitcodeIntoNewDbgInforFormat = cl::boolOrDefault::BOU_FALSE;

>From c471ff0c965a4356ef8660ffec3651bb94d87198 Mon Sep 17 00:00:00 2001
From: Orlando Cazalet-Hyams <orlando.hyams at sony.com>
Date: Mon, 25 Mar 2024 09:27:38 +0000
Subject: [PATCH 3/3] another whitespace

---
 llvm/tools/verify-uselistorder/verify-uselistorder.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
index 8ad24e40b8d980..8b299c394e4e5f 100644
--- a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -69,6 +69,7 @@ static cl::opt<unsigned>
                 cl::init(1), cl::cat(Cat));
 
 extern cl::opt<cl::boolOrDefault> LoadBitcodeIntoNewDbgInforFormat;
+
 namespace {
 
 struct TempFile {



More information about the llvm-commits mailing list