Skip to content

function pointer address space handling (for AVR) is wrong #106367

Closed
@RalfJung

Description

@RalfJung

@eddyb points out that the handling of address space for function pointers (introduced by #73270) is fundamentally wrong: PointeeInfo can be used for optimization hints only and also only becomes relevant way too late during compilation. To properly account for function pointers having a different address space, they need to be added in the Pointer variant of the Primitive ABI type. That is the only way to fix types like Result<&i32, fn()>, which are currently going horribly wrong for Harvard architectures because the enum layout algorithm will think that &i32 and fn() are exactly the same fundamental type, and put them into one and the same field (resulting LLVM layout: { i64, ptr }).

Not sure whom to ping here, so I will pick some people that seem to be active in an around AVR: @dylanmckay @Patryk27.
Also Cc @rust-lang/compiler since this is related to some pretty fundamental compiler infrastructure

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationO-AVRTarget: AVR processors (ATtiny, ATmega, etc.)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions