[llvm] r250207 - [AArch64] Check the size of the vector before accessing its elements.

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 11:55:34 PDT 2015


Author: ahatanak
Date: Tue Oct 13 13:55:34 2015
New Revision: 250207

URL: http://llvm.org/viewvc/llvm-project?rev=250207&view=rev
Log:
[AArch64] Check the size of the vector before accessing its elements.

This fixes an assert in AArch64AsmParser::MatchAndEmitInstruction.

rdar://problem/23081753

Modified:
    llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
    llvm/trunk/test/MC/AArch64/arm64-diags.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=250207&r1=250206&r2=250207&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Tue Oct 13 13:55:34 2015
@@ -3967,7 +3967,7 @@ bool AArch64AsmParser::MatchAndEmitInstr
     // suffix token operand.  The short-form match failure is probably more
     // relevant: use it instead.
     if (MatchResult == Match_InvalidOperand && ErrorInfo == 1 &&
-        ((AArch64Operand &)*Operands[1]).isToken() &&
+        Operands.size() > 1 && ((AArch64Operand &)*Operands[1]).isToken() &&
         ((AArch64Operand &)*Operands[1]).isTokenSuffix()) {
       MatchResult = ShortFormNEONMatchResult;
       ErrorInfo = ShortFormNEONErrorInfo;

Modified: llvm/trunk/test/MC/AArch64/arm64-diags.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/arm64-diags.s?rev=250207&r1=250206&r2=250207&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/arm64-diags.s (original)
+++ llvm/trunk/test/MC/AArch64/arm64-diags.s Tue Oct 13 13:55:34 2015
@@ -480,3 +480,12 @@ tlbi vale3
 ; CHECK-ERRORS: error: invalid operand for instruction
 ; CHECK-ERRORS:   b.eq 0, 0
 ; CHECK-ERRORS:           ^
+
+; Check that we give the proper "too few operands" diagnostic instead of
+; asserting.
+
+  ldr
+
+; CHECK-ERRORS: error: too few operands for instruction
+; CHECK-ERRORS:   ldr
+; CHECK-ERRORS:   ^




More information about the llvm-commits mailing list