<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - SelectInst::Create will crash when give name without giving insert point"
href="https://llvm.org/bugs/show_bug.cgi?id=27578">27578</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>SelectInst::Create will crash when give name without giving insert point
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Core LLVM classes
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tristan.yim@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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);</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>