Fix duplicated block in control flow uplifting #750
Merged
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.
What was wrong?
close #749
The problem is that the same basic block is included in serialized
StructuralInst
and then translated into yul more than once in the below CFG condition.e.g.,
In this CFG,
bb2
is amerge
block of two paths,bb0 -> bb1 -> bb4 -> bb2
andbb0 -> bb2
.But the compiler can't find merge block properly, and it lead to ICE as a result.
How was it fixed?
I wrongly assumed that
if
merge block should be the post dominator ofif
header.To find
if
merge block correctly, we should follow the below algorithm.1. Find
if
merge block candidateWhen we see the
branch
instruction in a non-loop header, we can find a merge block candidate by applying the following criteria to two destination blocks of thebranch
instruction respectively.2. Find
merge
block.We can find the merge block according to the result of
1.
.To-Do
OPTIONAL: Update Spec if applicable
Add entry to the release notes (may forgo for trivial changes)
Clean up commit history