larmel/lacc

Incorrect code generated for function calls in initializers

michaelforney opened this issue · 1 comments

Test case:

int id(int x) {
	return x;
}

int main(void) {
	int x[] = {id(1), id(0)};

	return x[1];
}

The generated assembly looks like it is setting up for a function call with two arguments (1, 0), then calling id twice with no changes to the argument registers in between.

Thank you for reporting this bug! The issue was that initializer parsing puttting all IR_ASSIGN statements in its own block does not work when assigning a call value, since it depends on parameters from previous IR_PARAM entries. I fixed this, together with a related problem with casts, in commit 94ef89f6fb.