[PATCH] D105372: [ms] [llvm-ml] Restrict implicit RIP-relative addressing to symbol references
Eric Astor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 2 13:18:51 PDT 2021
epastor created this revision.
epastor added reviewers: mstorsjo, thakis, rnk.
Herald added subscribers: pengfei, hiraditya.
epastor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
ML64.EXE applies implicit RIP-relative addressing only to memory references that include a symbol reference.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105372
Files:
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/test/tools/llvm-ml/rip-relative-addressing.asm
Index: llvm/test/tools/llvm-ml/rip-relative-addressing.asm
===================================================================
--- llvm/test/tools/llvm-ml/rip-relative-addressing.asm
+++ llvm/test/tools/llvm-ml/rip-relative-addressing.asm
@@ -1,8 +1,38 @@
-; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s --check-prefix=CHECK-32
-; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s --check-prefix=CHECK-64
+; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-32
+; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-64
+
+.data
+foo DWORD 28
.code
+
+t1:
+mov eax, foo
+; CHECK-LABEL: t1:
+; CHECK-32: mov eax, dword ptr [foo]
+; CHECK-64: mov eax, dword ptr [rip + foo]
+
+t2:
+mov eax, [foo]
+; CHECK-LABEL: t2:
+; CHECK-32: mov eax, dword ptr [foo]
+; CHECK-64: mov eax, dword ptr [rip + foo]
+
+t3:
+mov eax, [foo+2]
+; CHECK-LABEL: t3:
+; CHECK-32: mov eax, dword ptr [foo+2]
+; CHECK-64: mov eax, dword ptr [rip + foo+2]
+
+t4:
+mov eax, [2+foo]
+; CHECK-LABEL: t4:
+; CHECK-32: mov eax, dword ptr [foo+2]
+; CHECK-64: mov eax, dword ptr [rip + foo+2]
+
+t5:
mov eax, [4]
-; CHECK-32: mov eax, dword ptr [4]
-; CHECK-64: mov eax, dword ptr [rip + 4]
+; CHECK-LABEL: t5:
+; CHECK: mov eax, dword ptr [4]
+
END
\ No newline at end of file
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2594,9 +2594,9 @@
End, Size, SM.getSymName(),
SM.getIdentifierInfo(), Operands);
- // When parsing x64 MS-style assembly, all memory operands default to
- // RIP-relative when interpreted as non-absolute references.
- if (Parser.isParsingMasm() && is64BitMode()) {
+ // When parsing x64 MS-style assembly, all non-absolute references to a symbol
+ // default to RIP-relative.
+ if (Parser.isParsingMasm() && is64BitMode() && !SM.getSymName().empty()) {
Operands.push_back(X86Operand::CreateMem(getPointerWidth(), RegNo, Disp,
BaseReg, IndexReg, Scale, Start,
End, Size,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105372.356260.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210702/3a9e664a/attachment.bin>
More information about the llvm-commits
mailing list