<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 - PatchableFunction crashes on empty function"
href="https://bugs.llvm.org/show_bug.cgi?id=37958">37958</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>PatchableFunction crashes on empty function
</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>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>apilipenko@azulsystems.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I don't think that this is a problem for real world code, but it confuses
bugpoint and makes it reduce crashes down to empty method.
foo.ll:
define void @foo() "patchable-function"="prologue-short-redirect" {
unreachable
}
llc foo.ll
Stack dump:
0. Program arguments: /local/apilipenko/orca-2/build/buildR/bin/llc foo.ll
1. Running pass 'Function Pass Manager' on module 'foo.ll'.
2. Running pass 'Implement the 'patchable-function' attribute' on function
'@foo'
#0 0x00007f34f54eff9a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x603f9a)
#1 0x00007f34f54ee8da llvm::sys::RunSignalHandlers()
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x6028da)
#2 0x00007f34f54eea09 SignalHandler(int)
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x602a09)
#3 0x00007f34f4cdf130 __restore_rt (/lib64/libpthread.so.0+0xf130)
#4 0x00007f34f57aad44 llvm::MachineInstr::getMF() const
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x8bed44)
#5 0x00007f34f575cd4c
llvm::ilist_traits<llvm::MachineInstr>::removeNodeFromList(llvm::MachineInstr*)
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x870d4c)
#6 0x00007f34f57ab03f llvm::MachineInstr::eraseFromParent()
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x8bf03f)
#7 0x00007f34f584b53f (anonymous
namespace)::PatchableFunction::runOnMachineFunction(llvm::MachineFunction&)
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x95f53f)
#8 0x00007f34f57a6ff9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x8baff9)
#9 0x00007f34f55d0dba llvm::FPPassManager::runOnFunction(llvm::Function&)
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x6e4dba)
#10 0x00007f34f55d1614 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/local/apilipenko/orca-2/build/buildR/bin/../lib/liborca.so.0.dev+0x6e5614)
#11 0x00000000004123d4 main
(/local/apilipenko/orca-2/build/buildR/bin/llc+0x4123d4)
#12 0x00007f34f4100af5 __libc_start_main (/lib64/libc.so.6+0x21af5)
#13 0x00000000004128fd _start
(/local/apilipenko/orca-2/build/buildR/bin/llc+0x4128fd)
Segmentation fault (core dumped)
PatchableFunction finds the first instruction which is code generated (skipping
DBG_LABEL, DBG_VALUE, KILL, etc.) and replaces it with PATCHABLE_OP <minsize>,
<opcode>, <operands>, where <opcode> and <operands> are the first instruction
it found. If the function is empty it can't do this trick.
MachineBasicBlock::iterator FirstActualI = FirstMBB.begin();
for (; doesNotGeneratecode(*FirstActualI); ++FirstActualI)
assert(FirstActualI != FirstMBB.end());
... uses FirstActualI ...
Locally for my bugpoint run I fixed it by ignoring such functions but it seem
to violate the contract of "patchable-function".</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>