Make leader discovery reachability-aware - #18
Merged
Conversation
Unsupported JALR and SYSTEM encodings are decoded as K_ILL. K_ILL does not end a basic block, so constant propagation can cross an unreachable illegal word and resolve a later JALR. Make K_ILL end the block and stop CFG traversal. Add jump-over cases for a reserved JALR and a CSR word. Also stop the encoding test when PACK_WORDS fails. make check-all passes. Signed-off-by: thc1006 <hctsai1006@cs.nctu.edu.tw>
decode_graph() marks every static JAL and branch target as a leader, while resolve_jalr() does the same for targets resolved by block-local constant propagation. An unreachable transfer can therefore split a reachable block and make syscall analysis lose constants on the actual path. Seed leader discovery with a conservative reachability walk. Then recompute syscall classification, JALR targets, leaders, and reachability until the state is unchanged. Add off-path control-flow cases, an ecall reached only through a return, and run a chained JALR image to check its exact output. Keep the existing conservative rejection for a jump after an ecall that later proves to exit; this change does not retract leaders. make check-all passes. make fuzz-rvopt passes. Signed-off-by: thc1006 <hctsai1006@cs.nctu.edu.tw>
thc1006
force-pushed
the
rvopt-reachable-jalr-leaders
branch
from
August 3, 2026 12:28
f7aebc8 to
e43b54d
Compare
Collaborator
|
Thank @thc1006 for contributing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #13. The same leader-marking problem also affects direct JAL and branch targets. An unreachable control transfer can mark an instruction in a reachable block as a leader, causing
analyze_syscalls()to clear constant-propagation state and reject a validecall.Use a conservative reachability walk to seed leader discovery. Mark a transfer target as a leader only when the source instruction is reachable, then recompute syscall classification, JALR targets, leaders, and reachability to a fixed point.
Add off-path JAL, branch, and JALR regression cases. The chained-JALR case runs the emitted image and requires the exact output
AB. The existing RV32I test ELFs remain byte-for-byte identical.A pre-existing false rejection remains when code following an
ecallthat is later classified as an exit jumps back into an earlier block. This change preserves the conservative behavior and does not retract previously discovered leaders.make check-allpasses.make fuzz-rvoptpasses.Summary by cubic
Make leader discovery depend on reachability so off-path transfers no longer split live blocks and break syscall constant propagation. Also stop CFG traversal at illegal words and iterate syscall/JALR/leader/reachability until stable.
JALRtargets, leaders, and reachability to a fixed point; leaders only grow (conservative post-ecallbehavior preserved).K_ILLas a block end and stop CFG traversal.JALR/CSR cases, and a chained staticJALRimage that must print "AB"; fail fast when packing words.Written for commit e43b54d. Summary will update on new commits.