-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Aggregates and memory management in the IR is generally broken. #2819
Comments
Also currently So, the ASM gen around memory needs a lot of work. |
I'm also finding now that managing enums, which are tagged unions in IR and ASM, to be extremely painful in the current ASM gen. In particular, ensuring the padding around the union to make sure the memory accesses are aligned and correct in a union of types of different sizes is very clumsy and should be made explicit in IR with decent memory management. The workarounds in |
…o be inlined. If we don't we'll try to use the args as pointers and get an ICE. Will be fixed by #2819
…o be inlined. If we don't we'll try to use the args as pointers and get an ICE. Will be fixed by #2819
Also thinking that in IR there's no point in making distinctions between mutable pointers and immutable. That sort of correctness can be guaranteed by the compiler and so all pointers might as well be mutable. If we create code which tries to write to the data section then that's a compiler bug, not an issue with IR. |
Summary of discussion on slack:
|
This is the second step towards achieving #2819. Combining Type and Aggregate into a single data structure enables offset computations for complex indexing (i.e., a nesting of arrays and structs) which will be needed when we introduce GEPs. The new function `get_indexed_type` does this computation. The core of this PR is in `irtype.rs`. Everything else is just to accommodate that.
This is the second step towards achieving #2819. Combining Type and Aggregate into a single data structure enables offset computations for complex indexing (i.e., a nesting of arrays and structs) which will be needed when we introduce GEPs. The new function `get_indexed_type` does this computation. The core of this PR is in `irtype.rs`. Everything else is just to accommodate that. Co-authored-by: Joshua Batty <[email protected]>
Although the distinction between copy and reference types is more explicit within the compiler now, it wasn't always the case and this is apparent in the IR design.
E.g.,
store
andload
are used on entire aggregates as a blanket 'write' or 'read'.insert_value
andextract_value
were attempting to simplify using structs but just ambiguate them.get_ptr
was initially only for getting the address of locals but now it's for arguments too and should support globals.I propose at least the following fixes:
insert_value
,extract_value
,insert_element
andextract_element
and instead useget_ptr
,load
andstore
.load
andstore
are only for writing copy type values to a pointer.get_ptr
is improved to be more likeGEP
from LLVM.The text was updated successfully, but these errors were encountered: