<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - Crash in BitcodeReader.cpp under LTO"
href="https://bugs.llvm.org/show_bug.cgi?id=46750">46750</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Crash in BitcodeReader.cpp under LTO
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>chenmindong120@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23736" name="attach_23736" title="reduced c code">attachment 23736</a> <a href="attachment.cgi?id=23736&action=edit" title="reduced c code">[details]</a></span>
reduced c code
$ clang -O2 -flto=full test.c -o test.o
Or
$ llvm-dis test.o
llvm/lib/IR/Value.cpp:404: void llvm::Value::doRAUW(llvm::Value*,
llvm::Value::ReplaceMetadataUses): Assertion `New->getType() == getType() &&
"replaceAllUses of value with new value of different type!"' failed.
After some trouble shooting, I think the root is it's when parseConstants() in
BitcodeReader reads in a CST_CODE_CE_SELECT record, e.g.
select <selty><cond>, <ty><val1>, <ty><val2>
If “ty” here is a vector type and “cond” is a forward reference, LLVM uses i1
as the placeholder type of “cond” if it cannot find “cond” in ValueList, as the
code follows:
Type *SelectorTy = Type::getInt1Ty(Context);
// The selector might be an i1 or an <n x i1>
// Get the type from the ValueList before getting a forward ref.
if (VectorType *VTy = dyn_cast<VectorType>(CurTy))
if (Value *V = ValueList[Record[0]])
if (SelectorTy != V->getType())
SelectorTy = VectorType::get(SelectorTy, VTy->getNumElements());
However, the program aborts in RAUW() if we find “selty” is a vector type
later, because LLVM are trying to replace an i1 placeholder with an <n x i1>
value.</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>