Skip to content

[InstrProf] Fix single byte counters for elided branches - #5

Merged
luismarques merged 1 commit into
lowRISC:ot-llvm-16-hardeningfrom
sasdf:mgI695fd4b4
Jun 9, 2025
Merged

luismarques merged 1 commit into
lowRISC:ot-llvm-16-hardeningfrom
sasdf:mgI695fd4b4

Conversation

@sasdf

@sasdf sasdf commented Jun 9, 2025

Copy link
Copy Markdown

Single byte counters for elided branches in CGStmt::EmitIfStmt were not correctly incremented. In normal mode, the counter bound to the IfStmt counts the then arm, but in single-byte mode, it's intended to count the continuation block.

This patch adds the necessary increments for single-byte coverage mode in the elided branch case.

Reproducer

Before

 Line   Count
    1|      1|int main() {
    2|      1|  if (1) {
    3|      0|    return 0;
    4|      0|  }
    5|      1|  return 0;
    6|      1|}

After

 Line   Count
    1|      1|int main() {
    2|      1|  if (1) {
    3|      1|    return 0;
    4|      1|  }
    5|      0|  return 0;
    6|      1|}

Single byte counters for elided branches in `CGStmt::EmitIfStmt` were not
correctly incremented. In normal mode, the counter bound to the `IfStmt`
counts the `then` arm, but in single-byte mode, it's intended to count the
continuation block.

This patch adds the necessary increments for single-byte coverage mode in the
elided branch case.

Change-Id: I695fd4b46cf5b8e2333cbe820ac98c2e0cf2604d
Signed-off-by: Yi-Hsuan Deng <[email protected]>
@sasdf

sasdf commented Jun 9, 2025 •

Copy link
Copy Markdown
Author

@luismarques PTAL

Please also help us trigger a release after merging.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants