First Last Prev Next    No search results available
Details
: llvm-as crashes when labels are used in phi nodes
Bug#: 71
: libraries
: LLVM assembly language parser
Status: RESOLVED
Resolution: FIXED
: PC
: Linux
: 1.0
: P2
: minor
: 1.1

:
: crash-on-invalid
:
:
  Show dependency tree - Show dependency graph
People
Reporter: Andrew Whitehead <andrew.whitehead@utoronto.ca>
Assigned To: Chris Lattner <sabre@nondot.org>

Attachments


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2003-10-29 16:33
I'm not actually sure whether the following code should compile or not (whether
it's valid LLVM assembly), but it certainly shouldn't produce the output it
currently does. I would expect the code to either run through the blocks
A->C->B->C->A->C->...  or for llvm-as to give a syntax error.

Input (test.ll):

int %main() {
A:
    br label %C
B:
    br label %C
C:
    %next = phi label [%B, %A], [%A, %B]
    br label %next
}

Output (llvm-as test.ll):

llvm-as: /home/andrew/misc/llvm/include/Support/Casting.h:194: typename
cast_retty<To, From>::ret_type cast(const Y&) [with X = BasicBlock, Y = Value*]:
Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Aborted

Workaround (?):

int %main() {
A:
    br label %C
B:
    br label %C
C:
    %next = phi bool [false, %A], [true, %B]
    br bool %next, label %A, label %B
}
------- Comment #1 From Chris Lattner 2003-10-29 17:06:38 -------
That's not valid LLVM code, because label's aren't "first class" types.  In
other words, it not legal to produce values which are of label type.

This is still a bug however, because the llvm assembler should never crash like
that.  I'll fix it to output a happy little error message.  :)

-Chris
------- Comment #2 From Chris Lattner 2003-10-29 19:40:30 -------
Here are the clarifications to the documentation:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031027/008974.html

Here is the change to the parser:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031027/008975.html

And here is a bugfix to the "isFirstClassType" predicate that this made obvious:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031027/008976.html

The testcase now produces:
$ llvm-as test.ll
llvm-as: test.ll:8: PHI node operands must be of first class type!

Thanks for noticing this!

-Chris
------- Comment #3 From Andrew Whitehead 2003-10-29 20:01:43 -------
Thanks, that was quick. :)

Reading over your documentation update I see one tiny, niggling issue though,

"Only labels be used as the label arguments."
=> "Only labels _may_ be used as the label arguments."
------- Comment #4 From Chris Lattner 2003-10-29 22:36:19 -------
Indeed!
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031027/008979.html

Thanks!

-Chris

First Last Prev Next    No search results available