[llvm-bugs] [Bug 27578] New: SelectInst::Create will crash when give name without giving insert point
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Apr 29 13:55:44 PDT 2016
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: unassignedbugs at nondot.org
Reporter: tristan.yim at gmail.com
CC: llvm-bugs at lists.llvm.org
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160429/5d628597/attachment.html>
More information about the llvm-bugs
mailing list