https://llvm.org/bugs/show_bug.cgi?id=27578
Bug ID: 27578
Summary: SelectInst::Create will crash when give name without
giving insert point
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Core LLVM classes
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Code below will get an error, which is unexpected
BasicBlock *entry = BasicBlock::Create(Context, "", maxFunction);
Argument *Arg1 = &*iter;
iter++;
Argument *Arg2 = &*iter;
Value *Compare = Builder.CreateICmpULT(Arg1, Arg2, "c");
SelectInst *Select = SelectInst::Create(Compare,
Arg1, Arg2, "p1.p2");
Error is
While deleting: i1 %c
Use still stuck around after Def is destroyed: %p1.p2 = select i1 %c, i32 %p1,
i32 %p2
Assertion failed: (use_empty() && "Uses remain when a value is destroyed!"),
function ~Value, file /Users/hyan/code/llvm/llvm/lib/IR/Value.cpp, line 85.
Abort trap: 6
We have two static Create method for SelectInst
static SelectInst *Create(Value *C, Value *S1, Value *S2, const Twine &NameStr
= "", Instruction *InsertBefore = nullptr)
static SelectInst *Create(Value *C, Value *S1, Value *S2, const Twine &NameStr,
BasicBlock *InsertAtEnd)
First Create function should behave as InsertBefore to current insert point
even it's a nullptr. Otherwise this method will be useless.
Workaround for this is using second Create function
SelectInst *Select = SelectInst::Create(Compare,
Arg1, Arg2, "p1.p2", entry);
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs