Expected result: the offset addition gets folded into the relocation as an addend.
Actual result: the addition stays in code and turns into const + const after final linking.
We have a good number of cases in NativeAOT-LLVM where this optimization would kick in, e. g. we emit addresses of statics as @static_base + offset. This can be worked around by defining aliases for the referenced symbols, but that has compilation time cost.
Reproduction:
Expected result: the offset addition gets folded into the relocation as an addend. Actual result: the addition stays in code and turns into
const + const
after final linking.We have a good number of cases in NativeAOT-LLVM where this optimization would kick in, e. g. we emit addresses of statics as
@static_base + offset
. This can be worked around by defining aliases for the referenced symbols, but that has compilation time cost.