[PATCH] D87216: [NewPM] Support --print-before/after in NPM

Jamie Schmeiser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 12:36:13 PST 2020


jamieschmeiser added a comment.

I agree that having the callbacks ask for the names is an improvement as it is cleaner and allows other callbacks to use this feature if desired.  Generally, things look good.  I have a couple of minor concerns mentioned in the code but I think it would be acceptable as is if you don't agree with what I've mentioned.



================
Comment at: llvm/lib/Passes/PassBuilder.cpp:449
+  // We currently only use these for --print-before/after.
+  if (PIC && (!printBeforePasses().empty() || !printAfterPasses().empty())) {
+#define MODULE_PASS(NAME, CREATE_PASS)                                         \
----------------
The tests for the options being empty should be moved to a separate function to facilitate expanding this feature for use with other pass instrumentation callbacks.  Right now, this is buried in here and if another callback wished to also use this freature, it might be hard to find.   Pulling the test out into an aptly named function would make it easier to find and understand.


================
Comment at: llvm/lib/Passes/PassBuilder.cpp:467
+#include "PassRegistry.def"
+#ifndef NDEBUG
+    for (const auto &P : printBeforePasses()) {
----------------
This will silently give no tracing in release mode if the pass name does not exist (ie the error would not be reported and there would be no output).  Is this because of efficiency concerns?  It will only look for the names that are in the option list, which would typically be empty.  Rather than walking the string map, you could have a local stringset, add the pass names into it in the macros above if checking will be done and then use the stringset for the error checking.  I think this would be more efficient than walking the stringmap for producing the errors.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87216/new/

https://reviews.llvm.org/D87216



More information about the cfe-commits mailing list