<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55397>55397</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[IROutliner] MultiSource/Benchmarks/Prolangs-C++/simul larger with IR Outliner @ -Oz on AArch64
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:optimizations,
llvm:codesize
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ornata
</td>
</tr>
</table>
<pre>
At -Oz, simul is 6.59% larger with the IR outliner than without. This is a teensy tiny benchmark, but it does show a regression.
This was found by building the LLVM test suite with + without the IR outliner enabled using LNT, and comparing `size.__text`.
# Reproducing
IR for simul: https://godbolt.org/z/9P16365hG
```
# There are a bunch of functions, so let's do some horrible awk goop
~/llvm-project/build/bin/clang -Oz /tmp/simul-stripped.ll -Rpass-analysis=asm-printer -S -o /dev/null 2>&1| rg "\d+ instructions in function" -o | awk ' BEGIN { x=0 } { x+=$1 } END { print x}'
177
~/llvm-project/build/bin/clang -Oz /tmp/simul-stripped.ll -Rpass-analysis=asm-printer -mllvm -ir-outliner -S -o /dev/null 2>&1| rg "\d+ instructions in function" -o | awk ' BEGIN { x=0 } { x+=$1 } END { print x}'
188
```
Potential reduction: https://godbolt.org/z/xxr96zhTW
```
# No outliner
$ ~/llvm-project/build/bin/clang -Oz /tmp/test.ll -Rpass-analysis=asm-printer -S -o /dev/null
remark: <unknown>:0:0: 7 instructions in function [-Rpass-analysis=asm-printer]
remark: <unknown>:0:0: 7 instructions in function [-Rpass-analysis=asm-printer]
# -> 14 instructions
# Outliner
$ ~/llvm-project/build/bin/clang -Oz /tmp/test.ll -mllvm -ir-outliner -Rpass-analysis=asm-printer -S -o /dev/null
remark: <unknown>:0:0: 10 instructions in function [-Rpass-analysis=asm-printer]
remark: <unknown>:0:0: 10 instructions in function [-Rpass-analysis=asm-printer]
remark: <unknown>:0:0: 6 instructions in function [-Rpass-analysis=asm-printer]
# -> 26 instructions
```
# Analysis
I compiled everything with remarks + `-save-temps`.
Via `llvm-size-remark-diff`:
```
++ > outlined_ir_func_0, 6 instrs, 0 stack B
== < _GLOBAL__sub_I_simulate.cpp, -1 instrs, 0 stack B
== > _ZN17screen_controllerC1Eii, 3 instrs, 0 stack B
== > _ZN17screen_controllerC2Eii, 3 instrs, 0 stack B
### Summary ###
Total change:
instruction count: 11 (6.21%)
stack byte usage: None
```
>From there I took a look at `_ZN17screen_controllerC1Eii` and saw it was pretty much entirely being outlined:
<img width="1343" alt="Screen Shot 2022-05-11 at 6 11 25 PM" src="https://user-images.githubusercontent.com/4722725/167972261-5b3dc9a2-7619-4bba-9677-b0c98a07a3fd.png">
I extracted that function from the temporary bitcode and ran it through clang again with `-Oz -S -emit-llvm`. Then I used `llvm-extract` to yank out the function.
Since it was being outlined almost entirely, I just pasted it twice into a new IR file, resulting in a much smaller test case which seems to exhibit a related size increase.
cc: @AndrewLitteken
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNV1tvozgU_jXk5YgITIDmIQ9J04wqdTpVW81K-xIZcIKnYEe2aZr--j3HJOmk0-2OZmerlYAE43P7ztWFrnaTqYPwy3PAzsHKtmtAWsiG6ThgKTTcrIWBrXQ1uFrA5S3ozjVS4aKrufJfcGUI9zWS4cXBCaHsDpxUOyiEKuuWmwfiXnQOpINKCwu21lvca8TaCGulVsMgmgfRtH96ZltuYaU7VUGBjDrZVFKtvRZXV18_oxjrwHbSiV69gM0O2vygqlC8aEQFnSUWV9f3pA5HzqVuN9zQYpBFVj6L4XLpxJPDtxOFApbArdgYXXUl7v7-E8pZadNDFyRTqJ3bWPwTsAVea10VunFDbdb4hiAvxjdxlmRp_emEfxbtr6O4-1oYAZxutB5hBL2CFf5xiJb13tLQCBew3CKm-NYKqLUxEk0Fvn2AtdabPb_8AiU3zWMbog3fRIlUCw8p_UqFz7LhiALGAQK5cO0Gn96k0DojNxtRDZsGwtsNtzbkijc7K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