<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 --- - [InstCombine] Crash in InstructionCombining.cpp due to a cast failure in switch control condition"
href="https://llvm.org/bugs/show_bug.cgi?id=30486">30486</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[InstCombine] Crash in InstructionCombining.cpp due to a cast failure in switch control condition
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>s3rvac@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>InstCombine in LLVM 3.9 (and also in the current trunk, I checked this on rev.
282138) crashes in InstructionCombining.cpp due to a cast failure in switch
control condition.
Input:
------
@g = global i32 0
define i32 @func() {
switch i32 add (i32 ptrtoint (i32* @g to i32), i32 -1), label %x []
x:
ret i32 0
}
Run:
----
$ opt -instcombine input.ll -o output.bc
Output:
-------
0 libLLVM-3.9.so.1 0x00007fe0baa0e255
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1 libLLVM-3.9.so.1 0x00007fe0baa0c45e llvm::sys::RunSignalHandlers() + 62
2 libLLVM-3.9.so.1 0x00007fe0baa0c59a
3 libpthread.so.0 0x00007fe0bce108d0
4 libLLVM-3.9.so.1 0x00007fe0baa9ab9b llvm::Instruction::eraseFromParent() +
27
5 libLLVM-3.9.so.1 0x00007fe0bb0900bb
6 libLLVM-3.9.so.1 0x00007fe0bb098c36
7 libLLVM-3.9.so.1 0x00007fe0bb09a5f9
8 libLLVM-3.9.so.1 0x00007fe0bb09a87c
llvm::InstructionCombiningPass::runOnFunction(llvm::Function&) + 476
9 libLLVM-3.9.so.1 0x00007fe0baabe312
llvm::FPPassManager::runOnFunction(llvm::Function&) + 482
10 libLLVM-3.9.so.1 0x00007fe0baabe64b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
11 libLLVM-3.9.so.1 0x00007fe0baabe930
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 704
12 opt 0x000000000044d43a main + 7130
13 libc.so.6 0x00007fe0b99e8b45 __libc_start_main + 245
14 opt 0x0000000000457015
Stack dump:
0. Program arguments: opt -instcombine input.ll -o output.bc
1. Running pass 'Function Pass Manager' on module 'input.ll'.
2. Running pass 'Combine redundant instructions' on function '@func'
Segmentation fault
Expected output:
----------------
opt does not crash.
Cause:
------
There is the following code in
lib/Transforms/InstCombine/InstructionCombining.cpp
(LLVM trunk, rev. 282138):
2274 ConstantInt *AddRHS = nullptr;
2275 if (match(Cond, m_Add(m_Value(), m_ConstantInt(AddRHS)))) {
2276 Instruction *I = cast<Instruction>(Cond);
The cast<> on line 2276 fails when the condition (`Cond` variable) is as in the
input file. There needs to be a dyn_cast<> instead because the cast may fail
(as can be seen from this bug report).
Environment:
------------
- Official pre-build version of LLVM 3.9 for Debian Jessie (but the bug is
reproducible also in the current trunk, I checked that on rev. 282138).
- Fully updated Debian Jessie x86_64, GCC 4.9.2.</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>