Skip to content

[clang] No way to generate addrspacecast with C++ style cast #153526

@choikwa

Description

@choikwa

https://godbolt.org/z/zbrTTqMPv demonstrates C++ casts (static_cast, reinterpret_cast, etc) can't be used to generate addrspacecast. Only C style cast is lowered to addrspacecast. This is important for noalias analysis as addrspacecast is needed (vs PtrToInt) for ptr provenance and set appropriate alias.scope.

A typical scenario may be using reinterpret_cast<AS(n) T*>(reinterpret_cast<uintptr_t>(ptr)) but this inadvertently generates PtrToInt and IntToPtr which is considered as 'capturing' the pointer and llvm cannot trace it back to the underlying objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions