Count JALR return sites in loop promotion - #19
Merged
Conversation
successors() and the return-site table both treat a resolved 'jalr ra' as a call, so control comes back to the word after it. Loop promotion counted only 'jal ra' that way, so a loop entered through such a return looked single-entry. Promotion then attached its preload to the direct jump, and a run arriving by the return reached the loop without it and read a zeroed cell instead of guest memory. Share one is_link_call() predicate between the three passes. Add a hand-encoded image that enters its loop both ways and has to write B; counting only the direct jump makes it write 01. make check-all passes. make fuzz-rvopt passes. Signed-off-by: thc1006 <hctsai1006@cs.nctu.edu.tw>
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.
compute_promotions()counts the return site of a directjal ra, ...as an external loop entry, but misses the return site of a resolved
jalr ra, ....successors()and return-site collection treat bothas calls. A loop entered through the
jalr ra, ...return cantherefore look single-entry, so promotion attaches its preload only to
the direct-jump entry and execution through the return reads a zeroed
promotion cell.
The image below loads the word at address 84, increments it, stores it
back, then writes its low byte. The image emitted by
mainwrites0x01; the guest program should writeB(0x42).Use a shared
is_link_call()predicate insuccessors(),compute_promotions(), and return-site collection. Add an executableregression that lowers and runs the image and requires the exact output
B.The differential fuzzer does not cover this shape because generated
loop bodies contain no nested control flow. The current RV32I test
ELFs, including
rv32ui, lower to byte-identical images before andafter this change.
make check-allpasses.make fuzz-rvoptpasses.Summary by cubic
Fix loop promotion to count return sites from resolved
jalr ra, ...calls, so loops entered via ajalrreturn get the preload. Unifies call detection and adds a regression that must printB.is_link_call()and used it in successors, loop promotion, and return-site collection to treatjal raand resolvedjalr raconsistently.verify-muxcheck (RVOPT_LOOPCALL_ENC) that fails if the loop preload is bypassed; expects exact outputB.Written for commit 0fd2320. Summary will update on new commits.