Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Nov 14, 2023

Conversation

jmorse
Copy link
Member

@jmorse jmorse commented Nov 10, 2023

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 10a9e74.

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.
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 10, 2023

@llvm/pr-subscribers-debuginfo

Author: Jeremy Morse (jmorse)

Changes

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 10a9e74.


Full diff: https://github.com/llvm/llvm-project/pull/71937.diff

1 Files Affected:

  • (modified) llvm/tools/opt/opt.cpp (+19)
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);

Copy link

github-actions bot commented Nov 10, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

Comment on lines 447 to 458
// 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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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
}
// RemoveDIs debug-info transition: tests may request that we /try/ to use the
// new debug-info format, if it's built in.
#ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
if (TryUseNewDbgInfoFormat)
UseNewDbgInfoFormat = true;
#endif
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you wanted to add prints etc to the false branch, I don't think we need it?

Copy link
Collaborator

@pogo59 pogo59 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OCHyams might need a (void)TryUseNewDbgInfoFormat; outside the ifdef, to suppress an unused-variable warning in the iterators-off mode.

Copy link
Contributor

@OCHyams OCHyams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Comment on lines 447 to 458
// 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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you wanted to add prints etc to the false branch, I don't think we need it?

@jmorse
Copy link
Member Author

jmorse commented Nov 13, 2023

Pushed up some commits to simplify the diff, and also uh, test the flag after the command line options have actually been parsed (it's always-false otherwise). plus clang-format.

@jmorse jmorse merged commit da843aa into llvm:main Nov 14, 2023
3 checks passed
jmorse added a commit to jmorse/llvm-project that referenced this pull request Nov 14, 2023
DPValues are the non-intrinsic replacements for dbg.values, and when an IR
function is converted by SelectionDAG we need to convert the variable
location information in the same way. Happily all the information is in the
same format, it's just stored in a slightly different object, therefore
this patch refactors a few things to store the set of
{Variable,Expr,DILocation,Location} instead of just a pointer to a
DbgValueInst.

This also adds a hook in llc that's much like the one I've added to opt in
PR llvm#71937, allowing tests to optionally ask for the use RemoveDIs mode if
support for it is built into the compiler.

I've added that flag to a variety of SelectionDAG debug-info tests to
ensure that we get some coverage on the RemoveDIs / debug-info-iterator
buildbot.
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
…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
10a9e74.
jmorse added a commit that referenced this pull request Nov 21, 2023
)

DPValues are the non-intrinsic replacements for dbg.values, and when an
IR function is converted by SelectionDAG we need to convert the variable
location information in the same way. Happily all the information is in
the same format, it's just stored in a slightly different object,
therefore this patch refactors a few things to store the set of
{Variable,Expr,DILocation,Location} instead of just a pointer to a
DbgValueInst.

This also adds a hook in llc that's much like the one I've added to opt
in PR #71937, allowing tests to optionally ask for the use RemoveDIs
mode if support for it is built into the compiler.

I've added that flag to a variety of SelectionDAG debug-info tests to
ensure that we get some coverage on the RemoveDIs / debug-info-iterator
buildbot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants