[lld] [llvm] [ICF] Add a NOP after branch in ICF thunk to improve debugability (PR #154986)
Peter Rong via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 27 12:06:45 PDT 2025
DataCorrupted wrote:
Thanks for pointing that out!
But if you have three consecutive one-instruction functions (which would be a common case if you enable ICF safe thunks), they will be concat into one sequence: https://godbolt.org/z/GhrYP8njv
```
0x0000000000000000 1 12 1 0 0 0 is_stmt prologue_end
0x0000000000000010 2 12 1 0 0 0 is_stmt prologue_end
0x0000000000000020 3 12 1 0 0 0 is_stmt prologue_end
0x0000000000000021 3 12 1 0 0 0 is_stmt end_sequence
```
The problem we have here is, for ICF thunks to be probably symbolicated, each function needs to be its own sequence when we enable `-mllvm -emit-func-debug-line-table-offsets`: https://godbolt.org/z/qbndoGWbM
```
0x0000000000000000 1 12 1 0 0 0 is_stmt prologue_end
0x0000000000000000 1 12 1 0 0 0 is_stmt end_sequence
0x0000000000000010 2 12 1 0 0 0 is_stmt prologue_end
0x0000000000000010 2 12 1 0 0 0 is_stmt end_sequence
0x0000000000000020 3 12 1 0 0 0 is_stmt prologue_end
0x0000000000000021 3 12 1 0 0 0 is_stmt end_sequence
```
In this case, we can just advance PC, as the PC will go into other thunks.
https://github.com/llvm/llvm-project/pull/154986
More information about the llvm-commits
mailing list