From 9e5cf9c2c9ec498d87803f5f732a2d5417a0dbca Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Fri, 10 Nov 2023 10:22:34 +0000 Subject: [PATCH 1/4] [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 bb6627364442e..129f754eedda7 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -279,6 +279,12 @@ static cl::list PassPlugins("load-pass-plugin", cl::desc("Load passes from plugin library")); +static cl::opt TryUseNewDbgInfoFormat("try-experimental-debuginfo-iterators", + cl::desc("Enable debuginfo iterator positions, if they're built in"), + cl::init(false)); + +extern cl::opt 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 PluginList; PassPlugins.setCallback([&](const std::string &PluginPath) { auto Plugin = PassPlugin::Load(PluginPath); From 93b94f59a61f109d2182e5665c5aaba3b50e37ef Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Mon, 13 Nov 2023 14:26:55 +0000 Subject: [PATCH 2/4] Check flags after we've parsed the command line --- llvm/tools/opt/opt.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index 129f754eedda7..080ce4235ce79 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -444,19 +444,6 @@ 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 PluginList; PassPlugins.setCallback([&](const std::string &PluginPath) { auto Plugin = PassPlugin::Load(PluginPath); @@ -471,6 +458,19 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .bc modular optimizer and analysis printer\n"); + // 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 + } + LLVMContext Context; // TODO: remove shouldForceLegacyPM(). From d426d293f361b002f09696f83c979fe3ffb91975 Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Mon, 13 Nov 2023 14:33:24 +0000 Subject: [PATCH 3/4] Simplify away some un-necessary lines --- llvm/tools/opt/opt.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index 080ce4235ce79..81b3e1f240397 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -460,16 +460,14 @@ int main(int argc, char **argv) { // 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 (TryUseNewDbgInfoFormat) { // 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 } +#endif + (void)TryUseNewDbgInfoFormat; LLVMContext Context; From 4f8c8eaabbffa0fc68ae9f4cfdc0d2b4fc985c2a Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Mon, 13 Nov 2023 14:34:17 +0000 Subject: [PATCH 4/4] Clang-format --- llvm/tools/opt/opt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index 81b3e1f240397..5e5e5ce233f31 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -279,7 +279,8 @@ static cl::list PassPlugins("load-pass-plugin", cl::desc("Load passes from plugin library")); -static cl::opt TryUseNewDbgInfoFormat("try-experimental-debuginfo-iterators", +static cl::opt TryUseNewDbgInfoFormat( + "try-experimental-debuginfo-iterators", cl::desc("Enable debuginfo iterator positions, if they're built in"), cl::init(false));