[llvm] [BOLT][AArch64] Add support for LDR relaxtion on LDRSl/LDRDl/LDRQl (PR #196983)

Shanzhi Chen via llvm-commits llvm-commits at lists.llvm.org
Sat May 23 03:58:08 PDT 2026


chenshanzhi wrote:

Hi, @yozhu, thanks for your reply.

In fact, the statement "LivenessAnalysis may be expensive" originates from here:
https://github.com/llvm/llvm-project/blob/7bcc8e6f74bb8b38af3d539dc2cc36f8a16cc526/bolt/lib/Passes/RegReAssign.cpp#L282-L285

By saying "LivenessAnalysis may be expensive", what I mean is the underlying `DataflowAnalysis::run()` may be both time- and memory-consuming.

I don't have precise measurement data at the moment, but this PR https://github.com/llvm/llvm-project/pull/183704 includes test data based on a downstream version of BOLT where LivenessAnalysis is enabled for ICP on AArch64.

Theoretically, since the underlying `DataflowAnalysis::run()` requires traversing every `BinaryBasicBlock` in the entire `BinaryFunction` to calculate LiveIn/LiveOut state for every instruction, and each `ProgramPoint` uses a `BitVector` to store the state of all registers, this would make LivenessAnalysis a relatively expensive process.

The specific source code can be found in `DataflowAnalysis::run()` and the comment here gives a detailed explanation about how DataflowAnalysis works, taking LivenessAnalysis as an example:
https://github.com/llvm/llvm-project/blob/85c3fd048d7df66d093bfaf45e7c3c3ec44122bf/bolt/include/bolt/Passes/DataflowAnalysis.h#L120-L146

The memory cost is indicated in this comment. The key point is *"A dataflow analysis will associate a state with a program point."*.
https://github.com/llvm/llvm-project/blob/85c3fd048d7df66d093bfaf45e7c3c3ec44122bf/bolt/include/bolt/Passes/DataflowAnalysis.h#L22-L41

In fact, BOLT's AArch64 backend only supported LivenessAnalysis after PR https://github.com/llvm/llvm-project/pull/183298 was merged. And LivenessAnalysis for AArch64 hasn't been widely used yet. Therefore, I believe using it in this relatively simple scenario of LDR relaxation is a good starting point.

https://github.com/llvm/llvm-project/pull/196983


More information about the llvm-commits mailing list