Skip to content

Commit

Permalink
Reland [llvm-ml] Fix RIP-relative addressing for ptr operands (#108061)
Browse files Browse the repository at this point in the history
Relands #107618 with fix for assertion triggered by OpenMP runtime MASM
assembly source.

(cherry picked from commit 7574e1d)
  • Loading branch information
nga888 authored and tru committed Sep 24, 2024
1 parent de7ee2e commit 22139b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,8 @@ bool X86AsmParser::parseIntelOperand(OperandVector &Operands, StringRef Name) {
bool MaybeDirectBranchDest = true;

if (Parser.isParsingMasm()) {
if (is64BitMode() && SM.getElementSize() > 0) {
if (is64BitMode() &&
((PtrInOperand && !IndexReg) || SM.getElementSize() > 0)) {
DefaultBaseReg = X86::RIP;
}
if (IsUnconditionalBranch) {
Expand Down
12 changes: 11 additions & 1 deletion llvm/test/tools/llvm-ml/rip_relative_addressing.asm
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,14 @@ mov eax, [t8]
; CHECK-LABEL: t8:
; CHECK: mov eax, dword ptr [t8]

END
t9:
mov eax, dword ptr [bar]
; CHECK-LABEL: t9:
; CHECK-32: mov eax, dword ptr [bar]
; CHECK-64: mov eax, dword ptr [rip + bar]

t10:
mov ebx, dword ptr [4*eax]
; CHECK: mov ebx, dword ptr [4*eax]

END

0 comments on commit 22139b3

Please sign in to comment.