Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
My first attempt was to add an IR -> IR pass, but that approach doesn't work: in IR if/else/match are flattened into independent select nodes, losing which arms are nested (example 1) and which are just data-dependent (example 2).Without this information, gating conditions for cover nodes cannot be computed correctly. Example 1: Example 2: |
ee0b7a8 to
5f4b978
Compare
| std::optional<Span> span = node->GetSpan(); | ||
| if (span.has_value()) { | ||
| return absl::StrFormat( | ||
| "%s_%s_line_%d_pos_%d", function_name, then_arm ? "then" : "else", |
There was a problem hiding this comment.
_col_ would be more readable than _pos_ since "pos" means "position in the file" rather than "column on this line". Same comment elsewhere in this PR
5f4b978 to
945f226
Compare
|
I want to clarify the behavior of cover-related options. Currently, the |
945f226 to
b2e1cd2
Compare
|
I've updated the patch to properly handle if-else if-else chains. Previously, for an |
Yes, I think |
| not_any_prev_selected, | ||
| this_arm_selected}); | ||
| }); | ||
| if (options_.emit_auto_cover.Contains(AutoCoverKind::kBranch)) { |
There was a problem hiding this comment.
As mentioned in the main PR discussion, if the auto_cover is explicitly set to false, this should not run. Or you could do it when the flags are parsed.
There was a problem hiding this comment.
Done. Added ShouldEmitAutoCover method to ConvertOptions
Instrument each if/else-if/match arm with a cover op during DSLX -> IR conversion, where the original branch structure is still present. Covers are gated on the fully-nested reachability predicate (outer && inner), producing correct per-arm firing. Label format <fn>_<branch>_line_<N>_col_<M> (function, branch kind, line/col) to make it easier to find corresponding source location even without debug info (that is also supported). Enabled via `--emit_auto_cover=branch` (default off). Warns once per function when skipped due to a missing implicit token.
b2e1cd2 to
fcf5f23
Compare
Instrument each if/else-if/match arm with a cover op during DSLX -> IR conversion, where the original branch structure is still present. Covers are gated on the fully-nested reachability predicate (outer && inner), producing correct per-arm firing.
Label format
<fn>_<branch>_line_<N>_col_<M>(function, branch kind, line/col) to make it easier to find corresponding source location even without debug info (that is also supported). Enabled via--emit_auto_cover=branch(default off). Warns once per function when skipped due to a missing implicit token.