[llvm] 8cb8262 - [RISCV] Fix crash if you use an immediate as part of a vtype operand list.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu May 11 16:52:58 PDT 2023
Author: Craig Topper
Date: 2023-05-11T16:50:00-07:00
New Revision: 8cb8262de20b3199c8b037470294ca7909218924
URL: https://github.com/llvm/llvm-project/commit/8cb8262de20b3199c8b037470294ca7909218924
DIFF: https://github.com/llvm/llvm-project/commit/8cb8262de20b3199c8b037470294ca7909218924.diff
LOG: [RISCV] Fix crash if you use an immediate as part of a vtype operand list.
Added:
Modified:
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/MC/RISCV/rvv/invalid.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 03e00cbac8cda..9d45b7299a6e8 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2034,12 +2034,12 @@ OperandMatchResultTy RISCVAsmParser::parseJALOffset(OperandVector &Operands) {
OperandMatchResultTy RISCVAsmParser::parseVTypeI(OperandVector &Operands) {
SMLoc S = getLoc();
- if (getLexer().isNot(AsmToken::Identifier))
- return MatchOperand_NoMatch;
SmallVector<AsmToken, 7> VTypeIElements;
// Put all the tokens for vtypei operand into VTypeIElements vector.
while (getLexer().isNot(AsmToken::EndOfStatement)) {
+ if (getLexer().isNot(AsmToken::Identifier))
+ goto MatchFail;
VTypeIElements.push_back(getLexer().getTok());
getLexer().Lex();
if (getLexer().is(AsmToken::EndOfStatement))
diff --git a/llvm/test/MC/RISCV/rvv/invalid.s b/llvm/test/MC/RISCV/rvv/invalid.s
index 41f870963ef8d..16f64cf46fd55 100644
--- a/llvm/test/MC/RISCV/rvv/invalid.s
+++ b/llvm/test/MC/RISCV/rvv/invalid.s
@@ -77,6 +77,9 @@ vsetvli a2, a0, e8,m1
vsetvli a2, a0, e8,m1,ta
# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+vsetvli a2, a0, e8,1,ta,ma
+# CHECK-ERROR: operand must be e[8|16|32|64|128|256|512|1024],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]
+
vadd.vv v1, v3, v2, v4.t
# CHECK-ERROR: operand must be v0.t
More information about the llvm-commits
mailing list