Fix restoration of stack address after invoking function with struct-typed arguments #333

Merged
sb10q merged 2 commits from issue-233 into master 2023-10-06 11:35:27 +08:00
Collaborator

This PR places all allocas of struct arguments to the beginning of the function to prevent the stack pointer from permanently increasing after the function call returns.

The debug location changes are necessary as using gen_var will cause the debug location to be lost, causing the inlining pass to fail with inlinable function call in a function with debug info must have a !dbg location.

Fixes #233.

This PR places all `alloca`s of struct arguments to the beginning of the function to prevent the stack pointer from permanently increasing after the function call returns. The debug location changes are necessary as using `gen_var` will cause the debug location to be lost, causing the inlining pass to fail with `inlinable function call in a function with debug info must have a !dbg location`. Fixes #233.
derppening self-assigned this 2023-10-06 11:26:16 +08:00
derppening added 2 commits 2023-10-06 11:26:17 +08:00
1a54aaa1c0 core: Restore debug location when generating allocas
Debug location is lost when moving the builder cursor.
c9ef09cc48 core: Fix restoration of stack address
All allocas for temporary objects are now placed in the beginning of the
function. Allocas for on-temporary objects are not modified because
these variables may appear in a loop and thus must be uniquely
represented.
sb10q reviewed 2023-10-06 11:29:25 +08:00
@ -53,1 +53,4 @@
def dbg_stack_address(x):
i = 0
return uint64(id(i))

This expression with id doesn't make sense. Just exclude this test from the interpreter runs, or just return 0.

This expression with id doesn't make sense. Just exclude this test from the interpreter runs, or just return 0.
derppening force-pushed issue-233 from c9ef09cc48 to c7de22287e 2023-10-06 11:34:46 +08:00 Compare
Poster
Collaborator

v2: Changed Python implementation of dbg_stack_address to 0.

v2: Changed Python implementation of `dbg_stack_address` to 0.
sb10q merged commit c7de22287e into master 2023-10-06 11:35:27 +08:00
sb10q deleted branch issue-233 2023-10-06 11:35:30 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#333
There is no content yet.