<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99714>99714</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion failure in Hexagon constant-extender optimization from Hexagon Linux kernel
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:Hexagon
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nathanchance
</td>
</tr>
</table>
<pre>
After [a seemingly innocuous change in a filesystem driver in the Linux kernel](https://git.kernel.org/next/linux-next/c/fbb76c9f55205bd8a34164ba34b25411d45e7069), there is an assertion failure in the `Hexagon constant-extender optimization` pass. `cvise` spits out for a reproducer:
```c
enum { BCH_RECOVERY_PASS_scan_for_btree_nodes } six_lock_ip_waiter(long);
void trace_btree_path_lock(long);
static int __btree_node_lock_nopath(long ip) {
int ret = six_lock_ip_waiter(ip);
trace_btree_path_lock(({
__here:
(long) && __here;
}));
return ret;
}
void btree_node_lock_nopath_nofail() {
int ret = __btree_node_lock_nopath(({
__here:
(long) && __here;
}));
ret;
}
```
which can be crashed when using `-fno-PIE` (which the Linux kernel [uses](https://elixir.bootlin.com/linux/v6.10/source/Makefile#L566)):
```
$ clang --target=hexagon-linux -O2 -c -o /dev/null btree_io.i
btree_io.i:16:3: warning: expression result unused [-Wunused-value]
16 | ret;
| ^~~
1 warning generated.
$ clang --target=hexagon-linux -O2 -c -o /dev/null btree_io.i -fno-PIE
btree_io.i:16:3: warning: expression result unused [-Wunused-value]
16 | ret;
| ^~~
clang: /home/nathan/cbl/src/patched/tc-build/src/llvm-project/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp:745: bool (anonymous namespace)::HexagonConstExtenders::ExtRoot::operator<(const HCE::ExtRoot &) const: Assertion `ThisB->getParent() == OtherB->getParent()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang --target=hexagon-linux -O2 -c -o /dev/null btree_io.i -fno-PIE
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'btree_io.i'.
4. Running pass 'Hexagon constant-extender optimization' on function '@__btree_node_lock_nopath'
...
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVstv2zwS_2voy0CCRL3igw-OY6ELtGiQFLvYk0FRI4kbiRT4cJw99G__QEl2ktb5UBQ9fIZsi-QM5_WbBzNGtBJxQ7Jbkt2tmLOd0hvJbMck919cVap-2WwbixpIdsvAIA5Ctv0LCCkVd8oZ8KQtgpDAoBE9mhdjcYBaiyNqv207hM9CuhM8oZbYk-yO0JvO2tGQZEtoSWjZChvOp6HSLaGlxJMltOw9X7AsOKFlU1VFztdNltEoq-oblqRxnlYsSSuapXFcpxkWUb4mdE3ozsvWCMIAk8CMQW2FktAw0TuNZ-VIHn3CE2uVBK6ksUzaAE8WZY0a1GjFIP7PPCPJIxiZMaFn4Udh0O-YUVgDyllolAYGGketasdRe_OiOxKdf_Nofvi8RukGIMUt3O4-HR72u6__3j_893C_fXw8GM7koVH6UFmNeJCqRgOkuAMjTode8aeDGA_PTFjUhN70Srbe4OR2vvioRA1WM44L_8hsN7FdITaWWcFBSAuHN-JmKVJ51oULxEjo2ms8c8LEpNECST7QbOK4iIIPlfLP5drDwUft4jyYPq-aA6E5ofmF7HI5Ke6msL8VqNE6Lf3fZdOTvbrpusUHqTxIJs0-tPhv3PXOHoDfNekDi3425QKtt3h77gTvgDMJFQLXzHRYw3OHEpwRsvUgDhqpgvt_7T2OCb2ZOX5MWJ_7zqC5lrjYi5PQYaWU7YUMuRrOWUtoeczDOCK0NMppjoSWX9gT-hpBaPI5y_OzbdezZFnSFHjPZAtBYJluvfV33ZyuwSQIgq8UAg6BAkLLGo--fLi-X0IrVCjmq96sk22ck2SbkGQLz0xLIVv_iqdRozG-Rmg0rrfgpDNYew8E_5nfgyPrHXpfnEMZ50CKHbwPzRLiaZ9k--_f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