Skip to content

hir: dead constant elimination #59

@coderkalyan

Description

@coderkalyan

Because of the way type analysis is done, an integer/float literal that's used anywhere creates two instructions:
In step 1 (HirGen.zig reduction):
%0 = int(1234)
%1 = coerce(@Ref.u32, %0)

In step 2 (type_analysis.zig):
%0 = constant(@Ref.comptime_uint, 1234)
%1 = constant(@Ref.u32, 1234)

After type analysis, instruction %0 (the comptime_uint) constant is no longer needed, and is distracting. It's not breaking anything right now, but does need to be skipped. It would be nice to only have one relevant constant for i.e. top level declaration block_inline.

We should adapt the currently disabled dead_code_elimination into a dead_constant_elimination that removes the unused constants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions