Terminate both binary operator branches with *_end basic blocks #553
No reviewers
Labels
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#553
Loading…
Reference in New Issue
No description provided.
Delete Branch "occheung/nac3:nested-binop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Current Issue
Compiling boolean operations may cause panic. For example,
Boolean operation generates basic blocks
a
andb
. The program may branch to eithera
orb
depending of the first operand's value.The current implementation then generate unconditional branches to the controlling basic block
cont
with a PHI instruction to select result, but without knowing the current location.Hence, the following may happen:
a
orb
.a
andb
.cont
.a
andb
as the predecessor blocks.Patch
This PR renames existing
a
andb
intoa_begin
andb_begin
, and adds terminating basic blocksa_end
,b_end
. Generated expressions are branched to corresponding*_end
basic blocks, which branches back tocont
.Therefore, the PHI instruction in
cont
has known predecessors.The panic looks like this currently: