<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141310>141310</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[BOLT] RISCV tests rely on relocations that are not guaranteed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
BOLT
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MaskRay
</td>
</tr>
</table>
<pre>
bolt/test/RISCV tests are assembled using the default -mrelax. The generated object file contains redundant relocations, which will be removed by https://github.com/llvm/llvm-project/pull/140692
The two tests will fail unless I add back some relocations. @mtvec
```patch
diff --git a/bolt/test/RISCV/reloc-label-diff.s b/bolt/test/RISCV/reloc-label-diff.s
index 9ad38f86ff54..f1144767714b 100644
--- a/bolt/test/RISCV/reloc-label-diff.s
+++ b/bolt/test/RISCV/reloc-label-diff.s
@@ -20,4 +20,6 @@ _test_end:
.data
// CHECK: Hex dump of section '.data':
// CHECK: 0x{{.*}} 04000000
+ .reloc ., R_RISCV_ADD32, _test_end
+ .reloc ., R_RISCV_SUB32, _start
.word _test_end - _start
diff --git a/bolt/test/RISCV/reorder-blocks-reverse.s b/bolt/test/RISCV/reorder-blocks-reverse.s
index 6909fde59a48..6a9c87912827 100644
--- a/bolt/test/RISCV/reorder-blocks-reverse.s
+++ b/bolt/test/RISCV/reorder-blocks-reverse.s
@@ -7,6 +7,7 @@
.p2align 1
_start:
nop
+ .reloc ., R_RISCV_BRANCH, 1f
beq t0, t1, 1f
nop
beq t0, t2, 2f
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVF2P6yYQ_TXkZWQLY2ziBz84SaO96pe097avK2yGmC4xKeD9-PcVdtqNqvuxa1kyBs5wZuZwZAjmNCG2pNqR6rCRcxydb3-V4fFevm56p17b3tlI2DFiSJ_7T5_3f0L6CSA9ggwBz71FBXMw0wniiKBQy9lGyM4erXzJ4cuIcMIJvYyowPV_4RBBG4swuClKMwXwqOZJySmCR-sGGY2bAmF7eB7NMMKzsRZ6BI9n94QK-lcYY7wEUnaEHQk7nkwc5z4f3Jmwo7VP_36yi3fpOMKOl9lawo4Fp3XDCO0I7RKx-Oyu-SyHaGkszJPFEOATSKWgl8MjBHfGW2o5AOH0HJ9wgDUWqen6XmQcRkI7ZbSGLDuZCJKw41fqSNhxCZlZ2aPNEiAP0H9gM6GdmRS-QCNVudXbWuuK57kuCs5FLUTBeygorTkntMuy7ENMUlJst74fZUU4JZxCxihhew6E7ZZRDdeFhxTkASeVOkg7yJWMMg3WdsL-7qf9z6Ts4A5fQM3nCzgNAYdUfCBMrPuZuML_j6IvROyI2OWEdUQciDgA5XR51qwA8oU35Elk9w9LMg_d4VCyNPFG7zu7P_-xu-4OUfqYeADkz86rNzxkb6vvFITzCn3WWzc8hszjE_qAP5DF1yH_iaNuaKMVVo3k2zyvZTNsRVOwLRPvF8c3j3ifRL4NvwpFrOpguzQQV5lcS3ph0prTBEX6v5Zz7TvA5C7f69Huvvttf5dmCr0CevwbYtIixOJ2fg10u7z0lunbu71RbamaspEbbAvBt7SiTUU3Y1tvRcPZgLqvelqVshZsq7ZDKbDQQhfNxrSMsopWjNOCs5LmpRZlxZlAXde91jXhFM_S2DzZVu78aWNCmLEteFEWdLPcr7AYNWO733_5QhhLlu3bxeb6-RQIp9aEGN4iRBPtYu4LoDrArX17tK_gpltXgzjKuPj65CKcZunlFBHVZva2_bDhLvzDYrlLCk8t-ycAAP__9mby7w">