Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] 32bit pointer (-fms-extensions __ptr32 __uptr) has no effect in ARM64 #62536

Closed
d-mozulyov opened this issue May 3, 2023 · 2 comments · Fixed by #111879
Closed

[clang] 32bit pointer (-fms-extensions __ptr32 __uptr) has no effect in ARM64 #62536

d-mozulyov opened this issue May 3, 2023 · 2 comments · Fixed by #111879

Comments

@d-mozulyov
Copy link

d-mozulyov commented May 3, 2023

Problem

The 32-bit pointer does not work on platforms other than x64, such as Arm64. See the Godbolt listing.

Sample

#include <cstdint>

int param_std(int* foo) {
    int temp = *foo;
    *foo = 1;
    return temp + sizeof(foo);
}

int param_ptr32(int* __ptr32 __uptr bar) {
    int temp = *bar;
    *bar = 2;
    return temp + sizeof(bar);
}

int emulate_ptr32(uint32_t baz) {
    uint64_t baz64 = baz;
    int* bazptr = (int*)baz64;
    int temp = *bazptr;
    *bazptr = 3;
    return temp + sizeof(baz);
}

Conclusions

The param_ptr32 disassembler must be equal to emulate_ptr32, and different from param_std. Based on the Godbolt listing, the MSVC compiler does just that. But Clang does not take into account the 32-bit pointer under Arm64 (and most likely under other than x64). Its size is 8 bytes, disassembler param_std and param_ptr32 are the same.

@llvmbot
Copy link
Member

llvmbot commented May 3, 2023

@llvm/issue-subscribers-backend-aarch64

@alexandrvorobev
Copy link

alexandrvorobev commented Aug 26, 2023

For this issue proposed patches: D158857 , D158931

dpaoliello added a commit that referenced this issue Oct 15, 2024
…, __sptr, __uptr for AArch64 (#111879)

MSVC has a set of qualifiers to allow using 32-bit signed/unsigned
pointers when building 64-bit targets. This is useful for WoW code
(i.e., the part of Windows that handles running 32-bit application on a
64-bit OS). Currently this is supported on x64 using the 270, 271 and
272 address spaces, but does not work for AArch64 at all.

This change adds the same 270, 271 and 272 address spaces to AArch64 and
adjusts the data layout string accordingly. Clang will generate the
correct address space casts, but these will currently be ignored until
the AArch64 backend is updated to handle them.

Partially fixes #62536

This is a resurrected version of <https://reviews.llvm.org/D158857>
(originally created by @a_vorobev) - I've cleaned it up a little, fixed
the rest of the tests and added to auto-upgrade for the data layout.
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this issue Oct 16, 2024
…, __sptr, __uptr for AArch64 (llvm#111879)

MSVC has a set of qualifiers to allow using 32-bit signed/unsigned
pointers when building 64-bit targets. This is useful for WoW code
(i.e., the part of Windows that handles running 32-bit application on a
64-bit OS). Currently this is supported on x64 using the 270, 271 and
272 address spaces, but does not work for AArch64 at all.

This change adds the same 270, 271 and 272 address spaces to AArch64 and
adjusts the data layout string accordingly. Clang will generate the
correct address space casts, but these will currently be ignored until
the AArch64 backend is updated to handle them.

Partially fixes llvm#62536

This is a resurrected version of <https://reviews.llvm.org/D158857>
(originally created by @a_vorobev) - I've cleaned it up a little, fixed
the rest of the tests and added to auto-upgrade for the data layout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants