| Issue |
55397
|
| Summary |
[IROutliner] MultiSource/Benchmarks/Prolangs-C++/simul larger with IR Outliner @ -Oz on AArch64
|
| Labels |
llvm:optimizations,
llvm:codesize
|
| Assignees |
|
| Reporter |
ornata
|
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=""
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
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs