Skip to content
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

Type definitions in generator cause type errors #361

Open
Chobbes opened this issue Apr 4, 2024 · 0 comments
Open

Type definitions in generator cause type errors #361

Chobbes opened this issue Apr 4, 2024 · 0 comments
Assignees

Comments

@Chobbes
Copy link
Member

Chobbes commented Apr 4, 2024

Generating type definitions which will be used in generated LLVM programs currently causes problems. The generators were originally written under the assumption that a defined type is always equivalent to the fully normalized type (with no named types). This isn't true...

%name = type {i8}
%name2 = type {i8}

Named structure types are distinguished by name. So, %name, %name2, and {i8} are all considered to be different types.

Since we assumed otherwise before there are numerous places in the generator where using a named type causes problems. E.g., if we generate an expression of a named type we might generate a value of the unfolded type (given %name we might generate an {i8} instead). I've patched up a couple issues (I think) with regards to global constants, but more sneaky issues remain.

For instance extractvalue and insertvalue generators walk through a normalized type in order to find a path for indexing into a value. By normalizing the type, however, we lose the name information which can distinguish types later on, resulting in programs with type errors, e.g....:

    %v44 = extractvalue <{<{%v1, float}>}> %v43, 0
    %v48 = extractvalue <{{{{i8}, <{float, i64}>}, [0 x <2 x i32>], <3 x i64>}, float}> %v44, 0, 0, 1, 0

We lose the %v1 type distinction.

This is fixable, but we'll have to change how the paths are generated for these kinds of instructions.

@Chobbes Chobbes self-assigned this Apr 4, 2024
Chobbes added a commit that referenced this issue Apr 4, 2024
- Check structure types recursively for sized types
- Modify annotate function to pop stack.
- Add annotations for debugging to a lot of generators.
- Fix a bug in normalize_type_GenLLVM where pointer types were not
   normalized fully.
- Add a note about #361
  + Originally had fixed the is_sized_type_alias parameter, but this
      caused problems in other generators.
- Make normalized_typ_eq compare identifiers for types. This should
   probably be improved further (rename the function + make this
   follow identified type definitions when they're not
   structures. Related to the #361 issue).
- Avoid using normalized types in a few generators.
- Add gen_exp_possibly_non_deterministic to generate calls (as we now
   mark global pointers as non-deterministic).
- Fixed bug in gen_new_definition where function types would be
   generated inside vector types.
@Chobbes Chobbes added the bug label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant