Skip to content

Lower all semantically valid integer index expressions without LLVM panics #436

Closed

Description

@LunaStev

Summary

LLVM address generation accepts integer literals and a small set of lvalue expressions as array or pointer indices, then panics for other expression forms. Semantically valid indices such as arithmetic expressions, casts, and function results must not reach an unsupported backend panic.

Related issue

Relevant code

  • llvm/src/codegen/address.rs
  • expression lowering and typed expression information
  • semantic index validation

Scope

Use the normal typed integer expression lowering path for index operands, then normalize the resulting integer to the target index width. Keep address calculation and GEP invariants explicit.

Acceptance criteria

  • Literals, variables, arithmetic, grouped expressions, casts, field results, and function-call results work as indices when semantically valid.
  • Signed and unsigned integer widths are normalized deliberately.
  • Non-integer indices are rejected by the frontend with a source diagnostic.
  • No index expression can trigger Index int expr not supported yet or an equivalent panic.
  • Tests cover arrays, pointers, nested indexing, negative indices where permitted, and target-width differences.
  • Existing opaque-pointer and GEP safety invariants remain documented and valid.

Activity

  1. added
    bug
    help wanted
    needs testing
    technical debt
    on Aug 29, 2026
  2. LunaStev commented on Sep 8, 2026

    @LunaStev
    MemberAuthor

    Additional CI evidence from draft PR #520 at 2ae0a91c57fd76323124c0e4dff552adbfadbe1b:

    The LoongArch regression job fails loongarch64_shared_language_workloads_run_under_qemu before linking/execution. The new workload uses tag.bytes[i % 9] at shared/loong64/test5.wave:205, and semantic validation reports E3001: index expression must currently be an integer literal or integer lvalue.

    The LoongArch cases compile job reports the same expression. This supplies a concrete arithmetic-index acceptance case for this issue; it does not establish a LoongArch ABI or QEMU execution failure. Preserve the workload and support the valid typed index expression instead of hiding it behind a target skip.

    These are existing remote CI logs; no additional local reproduction was run during this audit.

  3. added a commit that references this issue on Sep 10, 2026
    3059ba8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wantedneeds testingtechnical debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions