[lld] [RISCV][LLD] Add RISCV zcmt optimise in linker relaxation (PR #77884)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 23:38:39 PST 2024


Xinlong-Wu wrote:

I tried linking several common applications and libraries using this patch to compare Zcmt's contribution to reducing Code Szie.

The results can be found in the [Sheet](https://docs.google.com/spreadsheets/d/1ZxGAim5V2tsFDu5WFA59dF4X2ba18DYCZxV0UwNhunI/edit?usp=sharing) or in the image below.

![image](https://github.com/llvm/llvm-project/assets/43398706/5accbdc3-9086-4ef7-898e-2090816e0159)

Besides that, I found a problem that needs to be discussed.

In  `TableJumpSection::finalizeContents()`, the linker will abort the tbljal optimization and empty the Jump table if tbljal optimization  would cause a negative optimization (i.e., the size reduction caused by the Table jump Inst is less than the size increase caused by making the Jump Table).

However, the linker still adds the symbol `__jvt_base$` to `.symtab` . This results in a small increase in program size.

Thus, I tried to delay adding the symbol `__jvt_base$` at lld/ELF/Writer.cpp and remove the symbol `__jvt_base$` when the Jump Table is not empty. Something like that

But it will crash with error placeholder symbol reached writer at `lld/ELF/Symbols.cpp:154`. Does anyone can point out anything else should I do to add symbol delay?

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


More information about the llvm-commits mailing list