-
Notifications
You must be signed in to change notification settings - Fork 989
Make log
functions variadic templates
#5243
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
Conversation
9cd0285
to
84bb9e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow, this too adds 1-2% runtime to the jpeg synthesis perf test, even on C++20 with LTO
I'm not seeing this. I'm seeing a small speedup instead (default build with C++17 and no LTO).
Can you recheck to make sure you made the comparison the right way around? |
I've updated this PR to have the That makes this PR performance-neutral for me instead of a small improvement. Interestingly, just converting |
422f9e7
to
8bebba7
Compare
OK, I'm not 100% sure what I'm doing here because the performance differences I'm seeing are pretty close to the noise floor on my machines, but I'm pretty sure that the commit converting |
I'm not sure what's up with the Ubuntu test failure; tests are passing for me. |
8bebba7
to
e847173
Compare
The failure for the "with Verific" builds is due to some of the logging functions being called from the non-public verific integration and the CI is using a cached build of those. We most likely also need to make coordinated changes to those non-public parts. I will prepare those, test the combination locally and report back. |
Now `log()` supports `std::string`. We have to fix a few places where the format parameter was not a compile time constant. This is mostly trivial.
…ed to be varargs.
…n-varags function
The YosysHQ Verific Extensions are compiled separately using their own stripped-down version of the Yosys headers. To maintain ABI compatibility with older extension builds post C++-ification of Yosys's logging APIs, which are backwards compatible on the API but not ABI level, this commit adds ABI compatible versions of a subset of the old logging API used by the extensions.
Instead of making those coordinated changes, I decided to add Also note that a C++20 build is already part of the "Compiler testing" workflow. |
What are the reasons/motivation for this change?
This makes all
log
-related functions supportstd::string
-related types directly, leveraging the work in PR #5221 which does this forstringf()
. This PR also adds support forstd::string_view
--- this is notable because printingstring_view
s using old-school varargs functions is hard because they're not null-terminated.After this lands, a lot of
.c_str()
boilerplate can be removed all over Yosys. It also enables fixing #5215 and #5210 in a clean way, because we can changelog_signal()
etc to return a temporary object or a string reference and not have to add.c_str()
.Support for more types, e.g. Yosys-specific types like
IdString
, could be easily added in the future. This also creates opportunities to improve performance (beyond what can be achieved with the old varargs implementation) if that matters.Explain how this is achieved.
Simple refactorings of each
log
-related function. Very few call sites needed to be updated (in seven places non-constant strings were being used for thelog()
format), so I think we can consider this source-compatible. Also when building with C++17 (the default) non-constant formats would still compile.Note that this builds PR #5221; the first two commits belong to that PR. Like that PR, this probably needs to land in conjunction with an update to the Verific prebuilt library.
If applicable, please suggest to reviewers how they can test the change.
Build with
CXXSTD=c++20
to get compile-time checking of the format strings. That should probably be enabled in CI after this lands.