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

[ARM] Incorrect calling convention when invoking __sync builtins #61880

Open
Amanieu opened this issue Apr 1, 2023 · 6 comments
Open

[ARM] Incorrect calling convention when invoking __sync builtins #61880

Amanieu opened this issue Apr 1, 2023 · 6 comments

Comments

@Amanieu
Copy link
Contributor

Amanieu commented Apr 1, 2023

IR

define void @foo(ptr %a, i32 %x) {
  %val = trunc i32 %x to i8
  %1 = atomicrmw max ptr %a, i8 %val seq_cst
  ret void
}

Asm

foo:
        push    {r11, lr}
        bl      __sync_fetch_and_max_1
        pop     {r11, lr}
        mov     pc, lr

The problem

The ARM calling convention specified that integers smaller than the word size need to be sign/zero-extended to the word size. __sync_fetch_and_max_1 expects a signed i8 for its second argument, which should be in sign-extended form. However LLVM isn't performing a sign-extension for this parameter, which leads to issues such as rust-lang/rust#100650.

@llvmbot
Copy link
Member

llvmbot commented Apr 1, 2023

@llvm/issue-subscribers-backend-arm

@brad0
Copy link
Contributor

brad0 commented Mar 8, 2024

@llvm/issue-subscribers-backend-arm

@brad0
Copy link
Contributor

brad0 commented Mar 30, 2024

@Amanieu Is this still an issue?

@Amanieu
Copy link
Contributor Author

Amanieu commented Mar 30, 2024

Yes: https://godbolt.org/z/r7fbP7W8h

The correct code should have a sign extension of r1.

@brad0
Copy link
Contributor

brad0 commented Mar 31, 2024

@brad0
Copy link
Contributor

brad0 commented Apr 5, 2024

cc @TNorthover @asl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants