llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.18k stars 12.04k forks source link

ARM cortex-m out of range pc-relative fixup value #88537

Open Tomal-kuet opened 7 months ago

Tomal-kuet commented 7 months ago

I added my custom instrumentation backend pass for ARM cortex-m33 CPU at the end of the addPreEmitPass2() function which is after ARMConstantIslandPass. In my custom pass, I do some instrumentation so the function size increases. My guess is as the function size increases the constant addresses go out of range for instructions such as vldr d11, [pc, #1008] . The highest pc relative access I found is 1008 without instrumentation and with my instrumentation it will be higher than 1020 (maximum limit?).

As a result, I am getting error: out of range pc-relative fixup value. Can you please suggest to me how this is fixable?

llvmbot commented 7 months ago

@llvm/issue-subscribers-backend-arm

Author: MD Armanuzzaman (Tomal-kuet)

I added my custom instrumentation backend pass for ARM cortex-m33 CPU at the end of the `addPreEmitPass2()` function which is after `ARMConstantIslandPass`. In my custom pass, I do some instrumentation so the function size increases. My guess is as the function size increases the constant addresses go out of range for instructions such as ` vldr d11, [pc, #1008]` . The highest `pc` relative access I found is 1008 without instrumentation and with my instrumentation it will be higher than 1020 (maximum limit?). As a result, I am getting **error: out of range pc-relative fixup value**. Can you please suggest to me how this is fixable?
davemgreen commented 7 months ago

Hi - could you move the pass to before ConstantIslandPass? (Or possibly during it).

As you explain, nothing should be increasing the distance between instructions after that point. You may be able to insert psuedo's before ConstantIslandPass with a known-maximum size, and replace the after. The code produced can be sub-optimal though.