[llvm] r330238 - [X86] Don't crash on bad operand modifiers in inline assembly
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 17 22:15:25 PDT 2018
Author: ctopper
Date: Tue Apr 17 22:15:24 2018
New Revision: 330238
URL: http://llvm.org/viewvc/llvm-project?rev=330238&view=rev
Log:
[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
Added:
llvm/trunk/test/CodeGen/X86/inline-asm-bad-modifier.ll
Modified:
llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=330238&r1=330237&r2=330238&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Tue Apr 17 22:15:24 2018
@@ -372,6 +372,12 @@ static bool printAsmMRegister(X86AsmPrin
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
Added: llvm/trunk/test/CodeGen/X86/inline-asm-bad-modifier.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inline-asm-bad-modifier.ll?rev=330238&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/inline-asm-bad-modifier.ll (added)
+++ llvm/trunk/test/CodeGen/X86/inline-asm-bad-modifier.ll Tue Apr 17 22:15:24 2018
@@ -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
+}
More information about the llvm-commits
mailing list