[llvm] [DebugInfo][RemoveDIs] Add flag to use "new" debug-info in opt (PR #71937)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 05:16:03 PST 2023


https://github.com/jmorse created https://github.com/llvm/llvm-project/pull/71937

Our option to turn on the non-intrinsic form of debug-info (`--experimental-debuginfo-iterators`) currently requires that LLVM is built with the `LLVM_EXPERIMENTAL_DEBUGINFO_ITERATORS` cmake flag enabled, so that some (slight) performance regressions aren't on-by-default during the prototype/testing period. However, we still want to be able to _optionally_ run tests, if support is built into LLVM.

To allow optionally exercising the non-intrinsic debug-info code, this patch adds `--try-experimental-debuginfo-iterators` to opt, which turns the `--experimental-debuginfo-iterators` flag on if support is built in, or leaves it off. This means we can run tests that:
 * Use normal dbg.value intrinsics if there's no support, or
 * Uses non-instruction DPValues if there is support.
  
Which means we can start getting test coverage of DPValues/RemoveDIs behaviour, from in-tree tests, on our RemoveDIs buildbot. All the code to do with automagically converting from one form to the other landed in 10a9e7442c4c4e.

>From 9e5cf9c2c9ec498d87803f5f732a2d5417a0dbca Mon Sep 17 00:00:00 2001
From: Jeremy Morse <jeremy.morse at sony.com>
Date: Fri, 10 Nov 2023 10:22:34 +0000
Subject: [PATCH] [DebugInfo][RemoveDIs] Add flag to use "new" debug-info  in
 opt

The option to turn on the non-intrinsic form of debug-info currently
requires that LLVM is built with the LLVM_EXPERIMENTAL_DEBUGINFO_ITERATORS
cmake flag enabled, so that some (slight) performance regressions aren't
on-by-default during the prototype/testing period. However, we still want
to be able to _optionally_ run tests, if support is built into LLVM.

Hence adding this flag, --try-experimental-debuginfo-iterators. This turns
the --experimental-debuginfo-iterators flag on if support is built in, or
leaves it off. This means we can run tests that:
 * Use normal dbg.value intrinsics if there's no support, or
 * Uses non-instruction DPValues if there is support.
Which means we can start getting test coverage of DPValues/RemoveDIs
behaviour, from in-tree tests, on our RemoveDIs buildbot.
---
 llvm/tools/opt/opt.cpp | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index bb6627364442ef7..129f754eedda71d 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -279,6 +279,12 @@ static cl::list<std::string>
     PassPlugins("load-pass-plugin",
                 cl::desc("Load passes from plugin library"));
 
+static cl::opt<bool> TryUseNewDbgInfoFormat("try-experimental-debuginfo-iterators",
+    cl::desc("Enable debuginfo iterator positions, if they're built in"),
+    cl::init(false));
+
+extern cl::opt<bool> UseNewDbgInfoFormat;
+
 //===----------------------------------------------------------------------===//
 // CodeGen-related helper functions.
 //
@@ -438,6 +444,19 @@ int main(int argc, char **argv) {
   initializeReplaceWithVeclibLegacyPass(Registry);
   initializeJMCInstrumenterPass(Registry);
 
+  // RemoveDIs debug-info transition: tests may request that we /try/ to use the
+  // new debug-info format, if it's built in.
+  if (TryUseNewDbgInfoFormat) {
+#ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
+    // If LLVM was built with support for this, turn the new debug-info format
+    // on.
+    UseNewDbgInfoFormat = true;
+#else
+    // It it wasn't, do nothing.
+    ;
+#endif
+  }
+
   SmallVector<PassPlugin, 1> PluginList;
   PassPlugins.setCallback([&](const std::string &PluginPath) {
     auto Plugin = PassPlugin::Load(PluginPath);



More information about the llvm-commits mailing list