llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Unnecessary vector type produces wrong ll parser error

Open arsenm opened this issue 10 years ago • 6 comments

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>

arsenm avatar Jul 22 '16 19:07 arsenm

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.

ekatz avatar May 01 '20 08:05 ekatz

@llvm/issue-subscribers-good-first-issue

llvmbot avatar Dec 10 '22 15:12 llvmbot

Can I work on this? if not please suggest a good first issue. Thanks!

bharsaklemukesh975 avatar Apr 26 '23 02:04 bharsaklemukesh975

Yes, you can work on it

arsenm avatar Apr 26 '23 02:04 arsenm

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

noahmbright avatar Oct 24 '24 17:10 noahmbright

@arsenm can I be the assignee if no one is actively working on it?

baberrehman avatar Nov 04 '26 12:11 baberrehman