[PATCH] D50790: [RISCV] Fixed SmallVector.h Assertion `idx < size()'

Ana Pazos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 30 12:44:27 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL341104:  [RISCV] Fixed SmallVector.h Assertion `idx < size()' (authored by apazos, committed by ).
Herald added a subscriber: jrtc27.

Changed prior to commit:
  https://reviews.llvm.org/D50790?vs=163393&id=163394#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50790

Files:
  llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/trunk/test/MC/RISCV/rv32i-invalid.s


Index: llvm/trunk/test/MC/RISCV/rv32i-invalid.s
===================================================================
--- llvm/trunk/test/MC/RISCV/rv32i-invalid.s
+++ llvm/trunk/test/MC/RISCV/rv32i-invalid.s
@@ -138,6 +138,8 @@
 # Too few operands
 ori a0, a1 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
 xor s2, s2 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
+# FIXME: Fix jal behavior to interpret a3 as a symbol rather than a register.
+jal a3     # CHECK: :[[@LINE]]:1: error: too few operands for instruction
 
 # Instruction not in the base ISA
 mul a4, ra, s0 # CHECK: :[[@LINE]]:1: error: instruction use requires an option to be enabled
Index: llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===================================================================
--- llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -684,7 +684,9 @@
                                              bool MatchingInlineAsm) {
   MCInst Inst;
 
-  switch (MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm)) {
+  auto Result =
+    MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm);
+  switch (Result) {
   default:
     break;
   case Match_Success:
@@ -705,6 +707,20 @@
     }
     return Error(ErrorLoc, "invalid operand for instruction");
   }
+  }
+
+  // Handle the case when the error message is of specific type
+  // other than the generic Match_InvalidOperand, and the
+  // corresponding operand is missing.
+  if (Result > FIRST_TARGET_MATCH_RESULT_TY) {
+    SMLoc ErrorLoc = IDLoc;
+    if (ErrorInfo != ~0U && ErrorInfo >= Operands.size())
+        return Error(ErrorLoc, "too few operands for instruction");
+  }
+
+  switch(Result) {
+  default:
+    break;
   case Match_InvalidImmXLen:
     if (isRV64()) {
       SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50790.163394.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180830/c95116ce/attachment.bin>


More information about the llvm-commits mailing list