Skip to content

Commit 7543d09

Browse files
authored
[llvm-ml] Fix RIP-relative addressing for ptr operands (#107618)
Fixes #54773
1 parent 7f90479 commit 7543d09

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2707,7 +2707,7 @@ bool X86AsmParser::parseIntelOperand(OperandVector &Operands, StringRef Name) {
27072707
bool MaybeDirectBranchDest = true;
27082708

27092709
if (Parser.isParsingMasm()) {
2710-
if (is64BitMode() && SM.getElementSize() > 0) {
2710+
if (is64BitMode() && (PtrInOperand || SM.getElementSize() > 0)) {
27112711
DefaultBaseReg = X86::RIP;
27122712
}
27132713
if (IsUnconditionalBranch) {

llvm/test/tools/llvm-ml/rip_relative_addressing.asm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,10 @@ mov eax, [t8]
5353
; CHECK-LABEL: t8:
5454
; CHECK: mov eax, dword ptr [t8]
5555

56-
END
56+
t9:
57+
mov eax, dword ptr [bar]
58+
; CHECK-LABEL: t9:
59+
; CHECK-32: mov eax, dword ptr [bar]
60+
; CHECK-64: mov eax, dword ptr [rip + bar]
61+
62+
END

0 commit comments

Comments
 (0)