-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Reland [llvm-ml] Fix RIP-relative addressing for ptr operands #108061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-backend-x86 Author: Andrew Ng (nga888) ChangesRelands #107618 with fix for assertion triggered by OpenMP runtime MASM assembly source. Full diff: https://github.com/llvm/llvm-project/pull/108061.diff 2 Files Affected:
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 03f49306c2b7b5..6b4e47a49eb17b 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems sensible to me - but @mstorsjo should probably check that this works on the OpenMP build too. (I'm less experienced with that.)
I've verified that the OpenMP object files assemble into bitexact the same thing as before, after this patch, and no asserts are triggered now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Relands llvm#107618 with fix for assertion triggered by OpenMP runtime MASM assembly source.
33438a2
to
240beb9
Compare
/cherry-pick 7574e1d |
…08061) Relands llvm#107618 with fix for assertion triggered by OpenMP runtime MASM assembly source. (cherry picked from commit 7574e1d)
/pull-request #109091 |
…08061) Relands llvm#107618 with fix for assertion triggered by OpenMP runtime MASM assembly source. (cherry picked from commit 7574e1d)
Relands #107618 with fix for assertion triggered by OpenMP runtime MASM assembly source.