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

[X86][MC] Linker error when using movdir64b #63045

Closed
akshaykhadse opened this issue Jun 1, 2023 · 2 comments
Closed

[X86][MC] Linker error when using movdir64b #63045

akshaykhadse opened this issue Jun 1, 2023 · 2 comments

Comments

@akshaykhadse
Copy link
Contributor

akshaykhadse commented Jun 1, 2023

Look at the following code:

int main(int argc, char *argv[]) {
    int arr[1000];
    __asm movdir64b rax, ZMMWORD PTR [arr]
    return 0;
}

Compiling this code using clang -O0 -fasm-blocks bug.c gives the a linker error.

But, according to Intel SDM address to 512-bit data should be supported:
image

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 1, 2023

@llvm/issue-subscribers-backend-x86

@akshaykhadse
Copy link
Contributor Author

akshaykhadse commented Jun 1, 2023

The problem seems to be in the generated assembly. Following is the out put of clang -S -O0 -fasm-blocks bug.c:
image
On line 20, the symbol arr should be replaced with some address like -4(%rbp).

This makes me believe that issue is not in the linker, but with the ASM parser.

This issue originates with patch D145893. And that's why reverting it fixes the issue. More specifically, the function isMem512_GR64() within the llvm/lib/Target/X86/AsmParser/X86Operand.h file.

akshaykhadse added a commit that referenced this issue Jun 8, 2023
This patch is to fix the [[ #63045 | issue 63045]].

Look at the following code:
```
int main(int argc, char *argv[]) {
    int arr[1000];
    __asm movdir64b rax, ZMMWORD PTR [arr]
    return 0;
}
```
Compiling this code using `clang -O0 -fasm-blocks bug.c` gives the a linker error.

The problem seems to be in the generated assembly. Following is the out put of `clang -S -O0 -fasm-blocks bug.c`:
```
movq %rsi, -16(%rbp)
#APP

movdir64b arr, %rax

#NO_APP
xorl %eax, %eax
```
The symbol `arr` should be replaced with some address like `-4(%rbp)`.

This makes me believe that issue is not in the linker, but with the ASM parser.

This issue originates with patch [D145893](https://reviews.llvm.org/D145893). And that's why reverting it fixes the issue. More specifically, the function [isMem512_GR64()](https://github.com/llvm/llvm-project/blob/ff471dcf7669b1ad7903a44d0773bef4eb175eb9/llvm/lib/Target/X86/AsmParser/X86Operand.h#L404) within the [llvm/lib/Target/X86/AsmParser/X86Operand.h](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/AsmParser/X86Operand.h) file.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D151863
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