问题
When I execute following IR:
declare void @_puts(i32, ...)
define void @main() {
entry:
%name = alloca i32
br i1 true, label %then, label %else
then: ; preds = %entry
call void (i32, ...) @_puts(i32 1, i32 1234)
br label %end
else: ; preds = %entry
br label %end
end: ; preds = %else, %then
%if_val = phi i32 [ 1234, %then ], [ 0, %else ]
entry1: ; No predecessors!
store i32 %if_val, i32* %name
%name2 = load i32, i32* %name
call void (i32, ...) @_puts(i32 1, i32 %name2)
ret void
}
I got following error message:
Assertion failed: (!NodePtr->isKnownSentinel()), function operator*, file /Users/Mac/llvm-source/llvm/include/llvm/ADT/ilist_iterator.h, line 139.
Abort trap: 6
What does this message means?
Can anyone explain this for me?
Thanks a lot.
回答1:
The message refers to a sentinel node of a simple_ilist, which is a data structure used for representing lists of functions in a module, basic blocks in a function, instructions in a basic blocks, and so on. A sentinel node represents the end of the list and is the only data member of such lists — the rest is inside the objects that constitute a list ("i" is for "intrusive").
I would guess that this message is caused by iterating over the end of a simple_ilist
. Most likely the one holding the instructions in the end
block, because this is the only block that is malformed. You can fix it by adding a terminator:
end: ; preds = %else, %then
%if_val = phi i32 [ 1234, %then ], [ 0, %else ]
br label %entry1
来源:https://stackoverflow.com/questions/43255774/llvm-what-does-nodeptr-isknownsentinel-function-operator-means