<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91175>91175</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[lld] Optimize calling one instruction function?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lld
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
metarutaiga
</td>
</tr>
</table>
<pre>
Does the LLD have the optimization option to reduce calling function when linking?
```
./one.o: file format mach-o arm64
Disassembly of section __TEXT,__text:
0000000000000000 <ltmp0>:
0: b9400400 ldr w0, [x0, #4]
4: d65f03c0 ret
0000000000000008 <_bar>:
8: a9bf7bfd stp x29, x30, [sp, #-16]!
c: 910003fd mov x29, sp
10: 94000000 bl 0x10 <_bar+0x8>
14: 11000400 add w0, w0, #1
18: a8c17bfd ldp x29, x30, [sp], #16
1c: d65f03c0 ret
```
When the LLD found the one instruction function, we can replace it.
```
10: 94000000 bl 0x10 <_bar+0x8>
```
to
```
10: b9400400 ldr w0, [x0, #4]
```
I know the LTO is better than this, but I haven't LTO libraries sometimes.
And the Debugger would be not to set breakpoint.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF1v4ygU_TX4BTUC_JH4wQ9tPZZGGmleKu2-RWCubbYYLMBNZn_9Cux02lGnq0GRHQj33HOOTi73Xo0GoEHlAyrbjK9hsq6ZIXC3Bq5GngkrfzStBY_DBPjbtxZP_AXSxi5BzepfHpQ1aWMNDhY7kGsPuOdaKzPiYTV9-ukygcFamWdlRpR3iLSI3O_PiuyftD0g1lkDB4vye7yvQWnAg3UzD3jm_XRnMXdzVbyFaZXn3sMs9A9sB-xha3w-P335-wmxx_M5wDWg_P5tEfllYZQ_6jAvBOVfXq_uJEgkJOqCkIKQ7UhLl94XgtgjRuXDdfvC8gKV7bvqIlbLqhxI3u_VDsInXE6Ry1lw9wGVUwTjtRiOYpDYhyWdXlkdu1_zGxu_7GzuaBX5MPoOpY8oNSWE5IPcjmb78hbKL3sBTeKj9uRSWkLvvlwpeeXKHsj1FBm_aUSTdhobvTrHpdxdu9wse0eObhJPPU0Sd7d_rzOq21CqG-X-M8ffZ257_hUzegv6YFcjt6QbwMr44NYtUbdMJ_Ix6gY7WDTvAatw-CTZu7KPrfzExV9ggv1f9D9P6YeGfMXPxl42S56-Y-WxgBDA4TDx6JTyEUesAX9Ng8EgdgzpqlbCcafAY29nCGoGvztzv7vagljHERy-2FVLLAAbG-IE8RCwcMCfF6tMOGSyyWWd1zyDhh5pUZ-qirFsaor-dOKCkyMt5Ykci7KnpCqK4ihlXsrymKmGEVaQklSkpoSxA-trKiWIKmcVL-WACgIzV_qg9ct8sG7MlPcrNDWlxzLTXID2aTgyprVEjMUp6Zp4-06so0cF0coH_7M-qKDTPI33yxZ_34bkz3n42yzlXbY63UwhLD7-21mHWDeqMK3i0NsZsS422V93i7P_QB8Q6xJjj1iXSP8XAAD__-1tlWM">