OSDN Git Service

X86AsmParser AVX-512: Return error instead of hitting assert
authorCraig Topper <craig.topper@intel.com>
Tue, 19 Feb 2019 17:13:40 +0000 (17:13 +0000)
committerCraig Topper <craig.topper@intel.com>
Tue, 19 Feb 2019 17:13:40 +0000 (17:13 +0000)
When parsing a sequence of tokens beginning with {, it will hit an assert and crash if the token afterwards is not an identifier. Instead of this, return a more verbose error as seen elsewhere in the function.

Patch by Brandon Jones (BrandonTJones)

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354356 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/X86/avx512-err.s

index 44173d9..cb5712c 100644 (file)
@@ -1654,6 +1654,8 @@ X86AsmParser::ParseRoundingModeOp(SMLoc Start) {
   const AsmToken &Tok = Parser.getTok();
   // Eat "{" and mark the current place.
   const SMLoc consumedToken = consumeToken();
+  if (Tok.isNot(AsmToken::Identifier))
+    return ErrorOperand(Tok.getLoc(), "Expected an identifier after {");
   if (Tok.getIdentifier().startswith("r")){
     int rndMode = StringSwitch<int>(Tok.getIdentifier())
       .Case("rn", X86::STATIC_ROUNDING::TO_NEAREST_INT)
index 31d5f4f..9d8183d 100644 (file)
@@ -11,3 +11,6 @@ vfmsub213ps %zmm8, %zmm8, %zmm8 {rn-sae}
 
 // ERR: invalid operand for instruction
 cvtsd2sil  {rn-sae}, %xmm1, %eax
+
+// ERR: Expected an identifier after {
+cvtsd2sil  {{sae}, %xmm1, %eax