diff options
author | Job Noorman <jnoorman@igalia.com> | 2023-10-05 08:55:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-05 08:55:30 +0000 |
commit | 7fa33773e355aaef03197e19698303748238d91a (patch) | |
tree | 8f8dad7a4670bd04834747313390a41d9e042b1f /clang/unittests/Lex/LexerTest.cpp | |
parent | d20fbc900783db3a87c8da622ede280d93f890bb (diff) | |
download | llvm-7fa33773e355aaef03197e19698303748238d91a.zip llvm-7fa33773e355aaef03197e19698303748238d91a.tar.gz llvm-7fa33773e355aaef03197e19698303748238d91a.tar.bz2 |
[BOLT][RISCV] Handle long tail calls (#67098)
Long tail calls use the following instruction sequence on RISC-V:
```
1: auipc xi, %pcrel_hi(sym)
jalr zero, %pcrel_lo(1b)(xi)
```
Since the second instruction in isolation looks like an indirect branch,
this confused BOLT and most functions containing a long tail call got
marked with "unknown control flow" and didn't get optimized as a
consequence.
This patch fixes this by detecting long tail call sequence in
`analyzeIndirectBranch`. `FixRISCVCallsPass` also had to be updated to
expand long tail calls to `PseudoTAIL` instead of `PseudoCALL`.
Besides this, this patch also fixes a minor issue with compressed tail
calls (`c.jr`) not being detected.
Note that I had to change `BinaryFunction::postProcessIndirectBranches`
slightly: the documentation of `MCPlusBuilder::analyzeIndirectBranch`
mentions that the [`Begin`, `End`) range contains the instructions
immediately preceding `Instruction`. However, in
`postProcessIndirectBranches`, *all* the instructions in the BB where
passed in the range. This made it difficult to find the preceding
instruction so I made sure *only* the preceding instructions are passed.
Diffstat (limited to 'clang/unittests/Lex/LexerTest.cpp')
0 files changed, 0 insertions, 0 deletions