[PATCH] D124413: [llvm-ml] Improve indirect call parsing

Alan Zhao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 13:08:09 PDT 2022


ayzhao created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
ayzhao requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In MASM, if a QWORD symbol is passed to a jmp or call instruction in
64-bit mode or a DWORD or WORD symbol is passed in 32-bit mode, then
MSVC's assembler recognizes that as an indirect call. Additionally, if
the operand is qualified as a ptr, then that should also be an indirect
call.

Furthermore, in 64-bit mode, such operands are implicitly rip-relative
(in fact, MSVC's assembler ml64.exe does not allow explicitly specifying
rip as a base register.)

To keep this patch managable, this patch does not include:

- error messages for wrong operand types (e.g. passing a QWORD in 32-bit mode)
- resolving indirect calls if the symbol is declared after it's first use (llvm-ml currently only runs a single pass).
- imlementing the extern keyword (required to resolve https://crbug.com/762167.)

This patch is likely missing a bunch of edge cases, so please do point
them out in the review.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124413

Files:
  llvm/include/llvm/MC/MCParser/MCAsmParser.h
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86Operand.h
  llvm/test/tools/llvm-ml/unconditional_branch_x64.asm
  llvm/test/tools/llvm-ml/unconditional_branch_x86.asm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124413.425007.patch
Type: text/x-patch
Size: 12396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220425/7df2c7cb/attachment.bin>


More information about the llvm-commits mailing list