<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 from IRBuilder with intrinsic already declared with type alias/substitute"
href="https://bugs.llvm.org/show_bug.cgi?id=40767">40767</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>crash from IRBuilder with intrinsic already declared with type alias/substitute
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>This is the same root cause as this fuzzer bug, but I made a slightly simpler
repro for instcombine:
<a href="https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13174">https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13174</a>
; Declaration with return type alias(?)
%0 = type { i32, i1 }
declare %0 @llvm.uadd.with.overflow.i32(i32, i32)
define i32 @no_carryin_i32(i32 %x, i32 %y, i8* %p) {
%s = call { i8, i32 } @llvm.x86.addcarry.32(i8 0, i32 %x, i32 %y)
%ov = extractvalue { i8, i32 } %s, 0
store i8 %ov, i8* %p
%r = extractvalue { i8, i32 } %s, 1
ret i32 %r
}
declare { i8, i32 } @llvm.x86.addcarry.32(i8, i32, i32)
----------------------------------------------------------------------------
The existing intrinsic declaration causes a crash when we try to create a new
call to that intrinsic using IRBuilder.
$ opt -instcombine addcarry.ll -S
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"),
function cast, file
/Users/spatel/GitHub/llvm-project/llvm/include/llvm/Support/Casting.h, line
254.
Stack dump:
0. Program arguments: ./opt -instcombine addcarry.ll -S
1. Running pass 'Function Pass Manager' on module 'addcarry.ll'.
2. Running pass 'Combine redundant instructions' on function
'@no_carryin_i32'
0 opt 0x00000001035e8ab8
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 opt 0x00000001035e79e8 llvm::sys::RunSignalHandlers() +
248
2 opt 0x00000001035e90d8 SignalHandler(int) + 264
3 libsystem_platform.dylib 0x00007fff75ac9b3d _sigtramp + 29
4 libsystem_platform.dylib 0x0000000000000020 _sigtramp + 2320721152
5 libsystem_c.dylib 0x00007fff759871c9 abort + 127
6 libsystem_c.dylib 0x00007fff7594f868 basename_r + 0
7 opt 0x0000000102f1d0d2
llvm::Intrinsic::getDeclaration(llvm::Module*, llvm::Intrinsic::ID,
llvm::ArrayRef<llvm::Type*>) + 210
8 opt 0x0000000102f2713e
llvm::IRBuilderBase::CreateIntrinsic(llvm::Intrinsic::ID,
llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<llvm::Value*>, llvm::Instruction*,
llvm::Twine const&) + 62
9 opt 0x00000001030fdc61
llvm::InstCombiner::visitCallInst(llvm::CallInst&) + 10929</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>