[llvm] r333524 - [AArch64][AsmParser] Fix segfault on illegal fpimm.

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Wed May 30 02:54:20 PDT 2018


Author: s.desmalen
Date: Wed May 30 02:54:19 2018
New Revision: 333524

URL: http://llvm.org/viewvc/llvm-project?rev=333524&view=rev
Log:
[AArch64][AsmParser] Fix segfault on illegal fpimm.

Floating point immediate combining a negative sign and
a hexadecimal number, e.g. #-0x0  caused the compiler to crash.

Reviewers: rengolin, fhahn, samparker, SjoerdMeijer, javed.absar

Reviewed By: javed.absar

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


Modified:
    llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/trunk/test/MC/AArch64/neon-diagnostics.s

Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=333524&r1=333523&r2=333524&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Wed May 30 02:54:19 2018
@@ -2283,9 +2283,9 @@ AArch64AsmParser::tryParseFPImm(OperandV
   const AsmToken &Tok = Parser.getTok();
   if (Tok.is(AsmToken::Real) || Tok.is(AsmToken::Integer)) {
     int64_t Val;
-    if (Tok.is(AsmToken::Integer) && !isNegative && Tok.getString().startswith("0x")) {
+    if (Tok.is(AsmToken::Integer) && Tok.getString().startswith("0x")) {
       Val = Tok.getIntVal();
-      if (Val > 255 || Val < 0) {
+      if (Val > 255 || isNegative) {
         TokError("encoded floating point value out of range");
         return MatchOperand_ParseFail;
       }

Modified: llvm/trunk/test/MC/AArch64/neon-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/neon-diagnostics.s?rev=333524&r1=333523&r2=333524&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/neon-diagnostics.s (original)
+++ llvm/trunk/test/MC/AArch64/neon-diagnostics.s Wed May 30 02:54:19 2018
@@ -279,10 +279,15 @@
 //----------------------------------------------------------------------
         // invalid vector type (2s, 4s, 2d)
          fmov v0.4h, #1.0
+         // invalid immediate (negative hexadecimal encoding)
+         fmov v0.4s, #-0x0
 
 // CHECK:ERROR: error: invalid operand for instruction
 // CHECK:ERROR:         fmov v0.4h, #1.0
 // CHECK:ERROR:              ^
+// CHECK-ERROR: error: encoded floating point value out of range
+// CHECK-ERROR:         fmov v0.4s, #-0x0
+// CHECK-ERROR:                     ^
 
 //----------------------------------------------------------------------
 // Vector Move -  register




More information about the llvm-commits mailing list