Skip to content

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Sep 18, 2024

Backport 7574e1d

Requested by: @mstorsjo

@llvmbot llvmbot added this to the LLVM 19.X Release milestone Sep 18, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Sep 18, 2024

@mstorsjo What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Sep 18, 2024

@llvm/pr-subscribers-backend-x86

Author: None (llvmbot)

Changes

Backport 7574e1d

Requested by: @mstorsjo


Full diff: https://github.com/llvm/llvm-project/pull/109091.diff

2 Files Affected:

  • (modified) llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp (+2-1)
  • (modified) llvm/test/tools/llvm-ml/rip_relative_addressing.asm (+11-1)
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index c7f88fed9b128b..efbcb57add98c9 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -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) {
diff --git a/llvm/test/tools/llvm-ml/rip_relative_addressing.asm b/llvm/test/tools/llvm-ml/rip_relative_addressing.asm
index d237e84435b7d6..c005b9721c07e0 100644
--- a/llvm/test/tools/llvm-ml/rip_relative_addressing.asm
+++ b/llvm/test/tools/llvm-ml/rip_relative_addressing.asm
@@ -53,4 +53,14 @@ mov eax, [t8]
 ; CHECK-LABEL: t8:
 ; CHECK: mov eax, dword ptr [t8]
 
-END
\ No newline at end of file
+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

@mstorsjo
Copy link
Member

@mstorsjo What do you think about merging this PR to the release branch?

Should be good; it fixes #54773 (fixing building LLVM without requiring MSVC's ml64.exe), and doesn't regress the OpenMP build which also uses llvm-ml. It has stayed in git main for a number of days without reported regressions now.

…08061)

Relands llvm#107618 with fix for assertion triggered by OpenMP runtime MASM
assembly source.

(cherry picked from commit 7574e1d)
@tru tru merged commit 22139b3 into llvm:release/19.x Sep 24, 2024
7 of 10 checks passed
Copy link

@mstorsjo (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants