Unnecessary vector type produces wrong ll parser error
| Bugzilla Link | 28669 |
| Version | trunk |
| OS | Linux |
| CC | @ekatz |
Extended Description
This testcase produces a misleading parse error
; RUN: llvm-as < %s
define void @add_v2i16(<2 x i16> addrspace(1)* %out, <2 x i16> %in) {
%arst = add <2 x i16> %in, <2 x i16> <i16 123, i16 456>
store <2 x i16> %arst, <2 x i16> addrspace(1)* %out
ret void
}
expected-type-wrong-error.ll:3:31: error: expected type
%arst = add <2 x i16> %in, <2 x i16> <i16 123, i16 456>
It is erroring on the 2nd operand <2 x i16> type, it really means the type is unexpected. The correctly parsing version is
%arst = add <2 x i16> %in, <i16 123, i16 456>
The full output is actually:
%arst = add <2 x i16> %in, <2 x i16> <i16 123, i16 456> ^
Notice the caret's location. The parser expects a type after the '<' token, as it expects the whole expression starting with '<' to be a Constant.
It might not be perfect, but it is correct. Maybe we can add more information about what it thinks it might be (it is actually a type instead of a constant). But then, it is no longer a bug, but a feature request, that probably should be opened in a separate issue.
@llvm/issue-subscribers-good-first-issue
Can I work on this? if not please suggest a good first issue. Thanks!
Yes, you can work on it
Hi, I'm interested in working on this as a first issue but I have a couple questions
What would the resolution here be? The parser would have to know it's parsing an add for two vectors, and the second < would indicate the start of a ConstVector, right? If it had that state, you could do a lookahead when you hit the < and check if the next token is a type for the ConstVector. Then you could give a more unambiguous error. That's my initial impression at least, not sure how reasonable it is to manage that
@arsenm can I be the assignee if no one is actively working on it?