[X86] Don't crash on bad operand modifiers in inline assembly

Summary: Previously if a modifer was placed on a non-GPR register class we would hit an assert or crash.

Reviewers: echristo

Reviewed By: echristo

Subscribers: eraman, llvm-commits

Differential Revision: https://reviews.llvm.org/D45751

llvm-svn: 330238
This commit is contained in:
Craig Topper 2018-04-18 05:15:24 +00:00
parent aea15131db
commit 8704612481
2 changed files with 14 additions and 0 deletions

View File

@ -372,6 +372,12 @@ static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO,
unsigned Reg = MO.getReg();
bool EmitPercent = true;
if (!X86::GR8RegClass.contains(Reg) &&
!X86::GR16RegClass.contains(Reg) &&
!X86::GR32RegClass.contains(Reg) &&
!X86::GR64RegClass.contains(Reg))
return true;
switch (Mode) {
default: return true; // Unknown mode.
case 'b': // Print QImode register

View File

@ -0,0 +1,8 @@
; RUN: not llc -mtriple=x86_64-- < %s 2>&1 | FileCheck %s
;CHECK: error: invalid operand in inline asm: 'vmovd ${1:x}, $0'
define i32 @foo() {
entry:
%0 = tail call i32 asm sideeffect "vmovd ${1:x}, $0", "=r,x,~{dirflag},~{fpsr},~{flags}"(<2 x i64> <i64 240518168632, i64 240518168632>)
ret i32 %0
}