Skip to content

[AArch64] Error when assembling call to function named ror #79729

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

Closed
zyedidia opened this issue Jan 28, 2024 · 2 comments · Fixed by #80571
Closed

[AArch64] Error when assembling call to function named ror #79729

zyedidia opened this issue Jan 28, 2024 · 2 comments · Fixed by #80571
Assignees

Comments

@zyedidia
Copy link
Contributor

zyedidia commented Jan 28, 2024

The following AArch64 assembly file fails to compile with Clang even though it is valid:

ror:
    ret

foo:
    bl ror
$ clang -c test.s
test.s:5:11: error: expected #imm after shift specifier
    bl ror
          ^
$ gcc -c test.s
$ # no error

ror or any other aarch64 shift operation should be a valid function/label name. Tested with the latest version of LLVM.

@pinskia
Copy link

pinskia commented Jan 28, 2024

You can also reproduce it with a C testcase with just -c -save-temps too:

int ror(void);
int f()
{
        return ror();
}

@llvmbot
Copy link
Member

llvmbot commented Jan 28, 2024

@llvm/issue-subscribers-backend-aarch64

Author: Zachary Yedidia (zyedidia)

The following AArch64 assembly file fails to compile with Clang even though it is valid:
ror:
    ret

foo:
    bl ror
$ clang -c test.s
test.s:5:11: error: expected #imm after shift specifier
    bl ror
          ^
$ gcc -c test.s
$ # no error

ror or any other aarch64 shift operation should be a valid function/label name. Tested with the latest version of LLVM.

@MaskRay MaskRay self-assigned this Feb 3, 2024
MaskRay added a commit that referenced this issue Feb 12, 2024
…modifier name (#80571)

Shift and extend modifiers are parsed as separate operands. When a
symbol operand of a branch instruction has such a "bad" name,
AArch64AsmParser will report an error.

```
% cat a.c
void lsl(); void lsr(); void asr(); void ror(); void uxtb(); void sxtx();
void foo() { lsl(); asr(); asr(); ror(); uxtb(); sxtx(); }
% clang --target=aarch64 -c -save-temps a.c
a.s:15:8: error: expected #imm after shift specifier
        bl      lsl
                   ^
a.s:16:8: error: expected #imm after shift specifier
        bl      asr
                   ^
a.s:17:8: error: expected #imm after shift specifier
        bl      asr
                   ^
a.s:18:8: error: expected #imm after shift specifier
        bl      ror
                   ^
a.s:19:5: error: expected label or encodable integer pc offset
        bl      uxtb
                ^
a.s:20:5: error: expected label or encodable integer pc offset
        bl      sxtx
                ^
```

In contrast, gas correctly parses these instructions.

Fix #79729 by parsing shift/extend modifier after an immediate
value/register
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants