[PATCH] D44031: [X86] Reject registers that require a REX prefix in inline asm constraints in 32-bit mode
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 6 11:01:40 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326826: [X86] Reject registers that require a REX prefix in inline asm constraints in… (authored by ctopper, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D44031?vs=137037&id=137239#toc
Repository:
rL LLVM
https://reviews.llvm.org/D44031
Files:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/asm-reject-rex.ll
llvm/trunk/test/CodeGen/X86/asm-reject-xmm16.ll
Index: llvm/trunk/test/CodeGen/X86/asm-reject-rex.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/asm-reject-rex.ll
+++ llvm/trunk/test/CodeGen/X86/asm-reject-rex.ll
@@ -0,0 +1,21 @@
+; RUN: not llc -o /dev/null %s -mtriple=i386-unknown-unknown 2>&1 | FileCheck %s
+; Make sure X32 still works.
+; RUN: llc -o /dev/null %s -mtriple=x86_64-linux-gnux32
+
+; CHECK: error: couldn't allocate output register for constraint '{xmm8}'
+define i64 @blup() {
+ %v = tail call i64 asm "", "={xmm8},0"(i64 0)
+ ret i64 %v
+}
+
+; CHECK: error: couldn't allocate output register for constraint '{r8d}'
+define i32 @foo() {
+ %v = tail call i32 asm "", "={r8d},0"(i32 0)
+ ret i32 %v
+}
+
+; CHECK: error: couldn't allocate output register for constraint '{rax}'
+define i64 @bar() {
+ %v = tail call i64 asm "", "={rax},0"(i64 0)
+ ret i64 %v
+}
Index: llvm/trunk/test/CodeGen/X86/asm-reject-xmm16.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/asm-reject-xmm16.ll
+++ llvm/trunk/test/CodeGen/X86/asm-reject-xmm16.ll
@@ -1,5 +1,5 @@
-; RUN: not llc -o /dev/null %s 2>&1 | FileCheck %s
-target triple = "x86_64--"
+; RUN: not llc -o /dev/null %s -mtriple=x86_64-unknown-unknown 2>&1 | FileCheck %s
+; RUN: not llc -o /dev/null %s -mtriple=i386-unknown-unknown -mattr=avx512vl 2>&1 | FileCheck %s
; CHECK: error: couldn't allocate output register for constraint '{xmm16}'
define i64 @blup() {
Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
@@ -39277,6 +39277,16 @@
return Res;
}
+ // Make sure it isn't a register that requires 64-bit mode.
+ if (!Subtarget.is64Bit() &&
+ (isFRClass(*Res.second) || isGRClass(*Res.second)) &&
+ TRI->getEncodingValue(Res.first) >= 8) {
+ // Register requires REX prefix, but we're in 32-bit mode.
+ Res.first = 0;
+ Res.second = nullptr;
+ return Res;
+ }
+
// Make sure it isn't a register that requires AVX512.
if (!Subtarget.hasAVX512() && isFRClass(*Res.second) &&
TRI->getEncodingValue(Res.first) & 0x10) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44031.137239.patch
Type: text/x-patch
Size: 2276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180306/841af79a/attachment.bin>
More information about the llvm-commits
mailing list