[PATCH] D150047: [X86][CodeGen] Do not add `offset` for memory reference using symbol

Alvin Wong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 6 11:39:41 PDT 2023


alvinhochun created this revision.
alvinhochun added reviewers: epastor, hans, thakis, MaskRay, ayzhao.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
alvinhochun requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In the past, D71436 <https://reviews.llvm.org/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 <https://reviews.llvm.org/D149579>.

Depends on D149579 <https://reviews.llvm.org/D149579>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150047

Files:
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/test/CodeGen/X86/ms-inline-asm-functions.ll
  llvm/test/CodeGen/X86/ms-inline-asm.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150047.520114.patch
Type: text/x-patch
Size: 5590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230506/1a3fea79/attachment.bin>


More information about the llvm-commits mailing list