Repository navigation
Reworking iree_status_t/iree::Status and improving error messages across the VM - #2849
Merged
Merged
Conversation
benvanik
force-pushed
the
benvanik-status
branch
5 times, most recently
from
August 12, 2020 03:01
8e9529f to
3c7c7c6
Compare
benvanik
marked this pull request as ready for review
August 12, 2020 15:30
benvanik
force-pushed
the
benvanik-status
branch
from
August 12, 2020 15:34
3c7c7c6 to
0709884
Compare
ScottTodd
reviewed
Aug 13, 2020
ScottTodd
left a comment
Member
There was a problem hiding this comment.
First batch of comments. Still looking through.
benvanik
force-pushed
the
benvanik-status
branch
from
August 13, 2020 15:53
0709884 to
7bdfc5e
Compare
benvanik
commented
Aug 13, 2020
benvanik
force-pushed
the
benvanik-status
branch
3 times, most recently
from
August 13, 2020 18:15
6af80ff to
e124913
Compare
ScottTodd
reviewed
Aug 13, 2020
benvanik
force-pushed
the
benvanik-status
branch
from
August 13, 2020 19:21
e124913 to
11f5404
Compare
benvanik
commented
Aug 13, 2020
benvanik
force-pushed
the
benvanik-status
branch
from
August 13, 2020 19:30
11f5404 to
46054c2
Compare
ScottTodd
approved these changes
Aug 14, 2020
ScottTodd
left a comment
Member
There was a problem hiding this comment.
Please wait a bit to merge while we sync the google/main branches and coordinate the Google branch details.
benvanik
force-pushed
the
benvanik-status
branch
from
August 14, 2020 00:57
91c88e2 to
2ff6ee6
Compare
ScottTodd
reviewed
Aug 14, 2020
benvanik
force-pushed
the
benvanik-status
branch
from
August 14, 2020 01:26
2ff6ee6 to
836e81e
Compare
ScottTodd
reviewed
Aug 14, 2020
Including the C++ file will enable support in the macro for Status.
benvanik
force-pushed
the
benvanik-status
branch
from
August 17, 2020 16:43
836e81e to
c34ef54
Compare
…2917) Otherwise the test fails in optimized builds (or other builds which disable annotations). I used macros instead of helper functions so we get line numbers for failed test checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #265 by implementing the described iree_status_t behavior and changing Status/StatusBuilder/StatusOr to wrap it. By doing this I was able to remove quite a bit of gunk that was required to move between the Google-style C++ Status and the API (such as ToApiStatus/FromApiStatus).
By being able to integrate iree_status_t into the C++ types I was also able to unify all of the macros - so IREE_CHECK_OK and IREE_RETURN_IF_ERROR can take either iree_status_t or Status/etc. Because the behavior is now different we can no longer use the iree/base/google/ versions and as such I've renamed all macros such that there are no collisions with the non-IREE versions.
Now, IREE_CHECK_OK/IREE_RETURN_IF_ERROR when used in C code can take optional printf-style arguments to add annotations to results, for example:
IREE_RETURN_IF_ERROR(OtherFunc(...), "with a value: %d", 5);When used in C++ the macros still accept printf-style arguments but can also use the ostream style:
IREE_RETURN_IF_ERROR(OtherFunc(...)) << "with a value: " << 5;. Though it's supported one shouldn't mix them!The most interesting changes in this branch are in iree/base/api.h + iree/base/api.c and the iree/base/internal/status* files. Other changes are mechanical cleanups required to avoid name conflicts, enable C compilation of core parts (or code to be used both in C and C++), and removing abseil deps from files that are C compatible.
A lot of focus was put on keeping the status usage - even if source location, messages, and stack traces are attached - from increasing codesize or overhead when on the happy success path. https://gcc.godbolt.org/z/xGsPc3
For example, this chain of calls and checks:

Ends up as the minimal possible code (while still having any kind of success checks):

The error handling cases are moved out of the way and (hopefully) kept out of cache. The handlers are able to hit the tail call optimization happy path and keeps the whole function code size smaller:
