Fix duplicate conflicting dead branch warnings due to loop unrolling#1960
Fix duplicate conflicting dead branch warnings due to loop unrolling#1960
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses confusing, duplicate, and even conflicting dead-branch warnings that occurred when loop unrolling was enabled, by attributing dead-branch tracking to the original (pre-unrolling) CFG node rather than to each unrolled copy.
Changes:
- Add a regression test ensuring loop unrolling no longer triggers spurious dead-branch warnings.
- In the dead-branch lifter, normalize
prev_nodeto the original statement node usingLoopUnrolling.find_original, aggregating unrolled copies under the same reporting key.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/regression/55-loop-unrolling/14-unrolled-loop-dead-branch.c | New regression test expecting no dead-branch warnings under loop unrolling. |
| src/lifters/specLifters.ml | Record dead-branch info under the original statement node to avoid duplicate/conflicting warnings from unrolled copies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c000003 to
faa85ec
Compare
|
Does this also fix the behavior for asserts that are in the unrolled loop? |
|
No, this is specific to the dead branch lifting which maintains its own global unknowns to aggregate over paths, contexts and now unrollings. When it comes to asserts (and pretty much all other messages), this makes no difference because it's all very text-based. Doing the same global unknowns aggregation for everything else would be quite messy. |
Previously the added test output contained
which is just plain confusing both sides of both conditions are live.
The branches are only dead in the internal unrolling of the loop and that's the point of loop unrolling.
It's strange that activating loop unrolling would previously generate more warnings.