Skip to content

Promote Copy aggregate arguments borrowed only by inlined device methods #400

Closed

Description

@niklebedenko

Problem

A copyable POD aggregate passed to a kernel by value can be forced into NVPTX local memory solely because an inlined helper method takes &self.

Observed flow:

  1. the kernel receives the aggregate by value;
  2. lowering creates an alloca so the caller can form &self;
  3. the helper performs runtime indexing into small fields through that pointer;
  4. after inlining, dynamic GEPs keep SROA from promoting the aggregate;
  5. PTX contains a local depot and ld.local / st.local.

A small mesh handle dropped from 56 bytes of local memory to zero when its read-only topology query used a value receiver, confirming that the borrow alone caused the frame. Larger kernel parameter bundles show the same retained-alloca shape, but changing every read-only method receiver in application code is not a scalable codegen contract.

Relationship to #397 / #398

#398 deliberately restricts selected-address scalarization to compiler-owned local arrays so external/shared pointers keep exactly one dynamic memory access. This issue concerns a compiler-owned alloca created from a by-value Copy argument after borrowing and inlining.

Desired result

Promote eligible compiler-owned Copy aggregates, including small runtime-indexed fields, without requiring application APIs to replace ordinary &self methods with value receivers. Preserve volatile behavior and do not speculate reads or writes through borrowed external pointers. Add a GPU regression asserting correct behavior and no PTX local-memory operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions