Skip to content

Commit

Permalink
updating eax_live_at_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
nlsandler committed Mar 27, 2024
1 parent 7dee6cb commit 97375e2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion expected_results.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@
"chapter_20/int_only/no_coalescing/use_all_hardregs.c": [
"chapter_20/libraries/util.c"
],
"chapter_20/int_only/no_coalescing/eax_live_at_exit.c": [
"chapter_20/libraries/util.c"
],
"chapter_20/int_only/no_coalescing/cmp_generates_operands.c": [
"chapter_20/libraries/util.c"
],
Expand Down
26 changes: 26 additions & 0 deletions tests/chapter_20/int_only/no_coalescing/eax_live_at_exit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Make sure we recognize that EAX is live at exit.
* Don't inspect assembly; just validate the program's behavior.
* Note: only works as intended once we've implemented register coalescing.
* */

#include "util.h"

int glob = 10;
int glob2 = 0;

// The first round of coalescing will coalesce x into EAX.
// Then, if we don't realize that EAX is live at exit, we'll
// coalesce the temporary that holds x + 100 into EAX, clobbering x.

int target(void) {
int x = glob + 1; // 11
glob2 = x + 100;
return x;
}

int main(void) {
int retval = target();
check_one_int(retval, 11);
check_one_int(glob2, 111);
return 0;
}
16 changes: 0 additions & 16 deletions tests/chapter_20/int_only/with_coalescing/eax_live_at_exit.c

This file was deleted.

0 comments on commit 97375e2

Please sign in to comment.