-
Notifications
You must be signed in to change notification settings - Fork 3
Stop analysis at illegal instructions #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,11 +321,13 @@ static int addr2node(const struct graph *g, uint32_t pc) | |
| return (idx >= 1 && idx < g->count) ? idx : NONE; | ||
| } | ||
|
|
||
| /* A control transfer ends a basic block; its successor starts a new one. */ | ||
| /* A control transfer ends a basic block, and so does an illegal word (nothing | ||
| * runs past one); its successor starts a new one. | ||
| */ | ||
| static bool is_block_end(int kind) | ||
| { | ||
| return kind == K_JAL || kind == K_JALR || kind == K_BRANCH || | ||
| kind == K_SYSTEM; | ||
| return kind == K_ILL || kind == K_JAL || kind == K_JALR || | ||
| kind == K_BRANCH || kind == K_SYSTEM; | ||
| } | ||
|
|
||
| /* Build the def-use lists from the vd1/vd2 producer edges: a flat pool indexed | ||
|
|
@@ -813,7 +815,7 @@ static void resolve_jalr(struct graph *g) | |
| * terminates) plus a branch/jump target. Writes up to 2 node indexes into | ||
| * succ[] and returns the count. Only 'jal ra' and resolved 'jalr ra,...' have a | ||
| * return site (matching the ret model); 'j', 'jal x5', and runtime JALR do not | ||
| * fall through; an ecall exit terminates. | ||
| * fall through; an ecall exit terminates, and so does an illegal word. | ||
| */ | ||
| static int successors(const struct graph *g, | ||
| const struct sysinfo *sys, | ||
|
|
@@ -826,7 +828,7 @@ static int successors(const struct graph *g, | |
| const int rd = (nd->word >> 7) & 31; | ||
| const bool link = rd == 1 && (nd->kind == K_JAL || | ||
| (nd->kind == K_JALR && nd->target != NONE)); | ||
| const bool terminates = (nd->kind == K_JAL && !link) || | ||
| const bool terminates = nd->kind == K_ILL || (nd->kind == K_JAL && !link) || | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes the illegal-word instance of a more general issue rather than the root cause. The underlying trigger is that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed. Replacing the illegal word with either I'll keep this PR scoped to treating |
||
| (nd->kind == K_JALR && !link) || | ||
| (nd->kind == K_SYSTEM && sys[i].kind == SYS_EXIT); | ||
| if (!terminates && fall != NONE) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good regression coverage: both cases reject without the
rvopt.cchange (unsupported op at pc 20) and accept with it, so they pin the behavior.