[all-commits] [llvm/llvm-project] 8cd90f: [X86][MC] Fix parsing Intel syntax indirect branch...

alvinhochun via All-commits all-commits at lists.llvm.org
Mon May 8 09:08:13 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8cd90fd1a8233b2dcb96451eab7c6baea3180f54
      https://github.com/llvm/llvm-project/commit/8cd90fd1a8233b2dcb96451eab7c6baea3180f54
  Author: Alvin Wong <alvin at alvinhc.com>
  Date:   2023-05-09 (Tue, 09 May 2023)

  Changed paths:
    M clang/test/CodeGen/ms-inline-asm-functions.c
    M llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
    A llvm/test/MC/X86/intel-syntax-branch.s

  Log Message:
  -----------
  [X86][MC] Fix parsing Intel syntax indirect branch with symbol only

Clang on Windows targets often requires indirect calls through the
import address table (IAT), and also .refptr stubs for MinGW target.
On 32-bit this generates assembly in the form of
`call dword ptr [__imp__func]`, which MC had failed to handle correctly.
64-bit targets are not affected because rip-relative addressing is used.

Reported on: https://github.com/llvm/llvm-project/issues/62010

Depends on D149695, D149920

Differential Revision: https://reviews.llvm.org/D149579


  Commit: 6b996282cee3588e46b18c30957e71c964012e14
      https://github.com/llvm/llvm-project/commit/6b996282cee3588e46b18c30957e71c964012e14
  Author: Alvin Wong <alvin at alvinhc.com>
  Date:   2023-05-09 (Tue, 09 May 2023)

  Changed paths:
    M llvm/lib/Target/X86/X86AsmPrinter.cpp
    A llvm/test/CodeGen/X86/ms-inline-asm-functions.ll
    M llvm/test/CodeGen/X86/ms-inline-asm.ll

  Log Message:
  -----------
  [X86][CodeGen] Do not add `offset` for memory reference using symbol

In the past, D71436 added writing the `offset` operator for some
legitimate cases. However, for memory references in Intel syntax, the
`offset` operator (`[offset sym]`) appears to be superfluous at best,
possibly wrong and contradictory at worst.

This patch bypasses writing the `offset` operator in
`X86AsmPrinter::PrintIntelMemReference` which affects exactly this
case. A similar code flow exists in `X86IntelInstPrinter.cpp` -
`X86IntelInstPrinter::printMemReference`.

The motivation for fixing this output is to allow us to reject the
confusing `call [offset fn_ref]` syntax in MC, as discussed in D149579.

Depends on D149579

Differential Revision: https://reviews.llvm.org/D150047


  Commit: 0ecd2e50146dd4dfac47b20a8e03e43a015b55ce
      https://github.com/llvm/llvm-project/commit/0ecd2e50146dd4dfac47b20a8e03e43a015b55ce
  Author: Alvin Wong <alvin at alvinhc.com>
  Date:   2023-05-09 (Tue, 09 May 2023)

  Changed paths:
    M llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
    M llvm/test/MC/X86/intel-syntax-branch.s

  Log Message:
  -----------
  [X86][MC] Reject `call`/`jmp [offset fn_ref]` in Intel syntax

This syntax is confusing and likely invalid. In addition, MASM rejects
it and GAS seems to behave oddly with it. Therefore we shall reject this
syntax for both unconditional `call` and `jmp` instructions, as
discussed in D149579.

Depends on D150047

Differential Revision: https://reviews.llvm.org/D150048


Compare: https://github.com/llvm/llvm-project/compare/81233c70cbf6...0ecd2e50146d


More information about the All-commits mailing list