Files
clang-p2996/llvm/test/CodeGen/X86/inline-asm-movdir64b.ll
Akshay Khadse 15f15ab2c8 [x86][MC] Fix movdir64b addressing
This patch is to fix the [[ https://github.com/llvm/llvm-project/issues/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()](ff471dcf76/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
2023-06-08 22:41:00 +08:00

22 lines
787 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+movdir64b | FileCheck %s --check-prefix=X86
define void @test_movdir64b() {
; X86-LABEL: test_movdir64b:
; X86: # %bb.0: # %entry
; X86-NEXT: subl $4000, %esp # imm = 0xFA0
; X86-NEXT: .cfi_def_cfa_offset 4004
; X86-NEXT: #APP
; X86-EMPTY:
; X86-NEXT: movdir64b (%esp), %eax
; X86-EMPTY:
; X86-NEXT: #NO_APP
; X86-NEXT: addl $4000, %esp # imm = 0xFA0
; X86-NEXT: .cfi_def_cfa_offset 4
; X86-NEXT: retl
entry:
%arr = alloca [1000 x i32], align 4
call void asm sideeffect inteldialect "movdir64b eax, zmmword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)
ret void
}