<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/100922>100922</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
BOLT could not find corresponding %pcrel_hi on RISC-V
</td>
</tr>
<tr>
<th>Labels</th>
<td>
BOLT
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
renndong
</td>
</tr>
</table>
<pre>
I'm trying to optimize a rust program using BOLT on RISC-V, but I get an error `<unknown>:0: error: could not find corresponding %pcrel_hi`.
This is the command that I execute:
```
llvm-bolt <executable> -o <output> -data=perf.fdata -reorder-blocks=ext-tsp -reorder-functions=hfsort -split-functions -split-all-cold -split-eh -dyno-stats
```
and the BOLT version and rust compiler version I use are:
```
$ llvm-bolt --version
LLVM (http://llvm.org/):
LLVM version 19.0.0git
Optimized build with assertions.
BOLT revision 3d72c44fedc13ef51d2584b4fe930edb8d2e87ae
Registered Targets:
riscv32 - 32-bit RISC-V
riscv64 - 64-bit RISC-V
$ rustc -v -V
rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: riscv64gc-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6
```
The output of BOLT is as follows:
<details>
<summary>Output</summary>
```
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: riscv64
BOLT-INFO: BOLT version: 3d72c44fedc13ef51d2584b4fe930edb8d2e87ae
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x200000, offset 0x200000
BOLT-WARNING: debug info will be stripped from the binary. Use -update-debug-sections to keep it.
BOLT-INFO: enabling relocation mode
BOLT-INFO: disabling -align-macro-fusion on non-x86 platform
BOLT-WARNING: Failed to analyze 41 relocations
BOLT-INFO: pre-processing profile using branch profile reader
BOLT-INFO: operating with basic samples profiling data (no LBR).
BOLT-INFO: normalizing samples by instruction count.
BOLT-INFO: 83 out of 640 functions in the binary (13.0%) have non-empty execution profile
BOLT-INFO: basic block reordering modified layout of 38 functions (45.78% of profiled, 5.41% of total)
BOLT-INFO: UCE removed 4 blocks and 8 bytes of code
BOLT-INFO: 0 Functions were reordered by LoopInversionPass
BOLT-INFO: program-wide dynostats after all optimizations before SCTC and FOP:
276799252 : executed forward branches
83592209 : taken forward branches
19175433 : executed backward branches
1975284 : taken backward branches
230588915 : executed unconditional branches
217290399 : all function calls
217290399 : indirect calls
0 : PLT calls
5363549217 : executed instructions
1360261461 : executed load instructions
1652341608 : executed store instructions
0 : taken jump table branches
0 : taken unknown indirect branches
526563600 : total branches
316156408 : taken branches
210407192 : non-taken conditional branches
85567493 : taken conditional branches
295974685 : all conditional branches
286282669 : executed forward branches (+3.4%)
6522058 : taken forward branches (-92.2%)
9692016 : executed backward branches (-49.5%)
6625161 : taken backward branches (+235.4%)
11381856 : executed unconditional branches (-95.1%)
217290399 : all function calls (=)
1324278 : indirect calls (-99.4%)
0 : PLT calls (=)
4735678411 : executed instructions (-11.7%)
1360261461 : executed load instructions (=)
1652341608 : executed store instructions (=)
0 : taken jump table branches (=)
0 : taken unknown indirect branches (=)
307356541 : total branches (-41.6%)
24529075 : taken branches (-92.2%)
282827466 : non-taken conditional branches (+34.4%)
13147219 : taken conditional branches (-84.6%)
295974685 : all conditional branches (=)
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
<unknown>:0: error: could not find corresponding %pcrel_hi
BOLT-ERROR: Emission failed.
```
</details>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWUlv3DoS_jXypSCBIrUe-pB4GRjwxIGf35vjgBJL3UwkUSApL_n1A1LqzVHbfsCcHloIOhFZ9dWir6oUkRsj1z3iKki_BunVBR_tRumVxr4Xql9fVEq8rm4Dmndg9avs12AVqMHKTv5C4KBHY2HQaq15B6NxAl_v7x5B9fBw-8dl-FdAL6EaLdzCGi3wHlBrpSHISMAux_5nr577gF0H7AsJ2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