Top Banner
Link-Time Optimization on PlayStation®4 Yunzhong Gao Sony Computer Entertainment LLVM Dev Meeting, 28-29 Oct 2014
25

Link-Time Optimization - LLVM

Dec 11, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Link-Time Optimization - LLVM

Link-Time Optimization

on PlayStation®4

Yunzhong Gao Sony Computer Entertainment

LLVM Dev Meeting, 28-29 Oct 2014

Page 2: Link-Time Optimization - LLVM

Last Year… • LTO without linker

Combined bc file

llvm-link

opt

object file

llc

Output executable

PS4TM

linker PS4TM linker

Input bc files Input object files

Page 3: Link-Time Optimization - LLVM

• LOTS of contribution from the community

• Thank you!

• Reference: see Rafael’s talk at Euro LLVM 2014

Past work in LTO…

Page 4: Link-Time Optimization - LLVM

In the Linker… • Proprietary linker

Page 5: Link-Time Optimization - LLVM

In the Linker… • Proprietary linker

• Uses tools/LTO interface • lto_module_is_object_file()

Page 6: Link-Time Optimization - LLVM

Input bc files Input object files

In the Linker…

Page 7: Link-Time Optimization - LLVM

Input bc files Input object files

In the Linker…

Scan Phase

for each bc file: • lto_module_get_symbol_name()

• lto_module_get_symbol_attribute()

• lto_module_get_deplib()

• lto_codegen_add_module()

Page 8: Link-Time Optimization - LLVM

Input bc files Input object files

Scan Phase

In the Linker…

Page 9: Link-Time Optimization - LLVM

Input bc files Input object files

Scan Phase

In the Linker…

Compile Phase

• lto_codegen_add_must_preserve_symbol()

• lto_codegen_compile_to_file()

Page 10: Link-Time Optimization - LLVM

Input bc files Input object files

Scan Phase

Compile Phase

In the Linker…

Page 11: Link-Time Optimization - LLVM

Input bc files Input object files

Object file

Scan Phase

Compile Phase

In the Linker…

Page 12: Link-Time Optimization - LLVM

Input bc files Input object files

Object file

Scan Phase

Compile Phase

Output executable

Usual linking steps Usual linking steps

In the Linker…

Page 13: Link-Time Optimization - LLVM

Whose Bug?

Clearly, this is a bug

in the LTO library.

No, CLEARLY, it is

a linker problem.

Page 14: Link-Time Optimization - LLVM

Whose Bug?

wrapper

LTO.dll

Linker

commands

results

Page 15: Link-Time Optimization - LLVM

Whose Bug?

wrapper

Linker

commands

results

Cannot select: 0x2e329d0:

v4i32 = …

Page 16: Link-Time Optimization - LLVM

Whose Bug?

wrapper

LTO.dll

Linker

commands

results

Page 17: Link-Time Optimization - LLVM

Whose Bug?

wrapper

LTO.dll

results

A list of

commands

stdout

Page 18: Link-Time Optimization - LLVM

Evaluation

Results on some PS4TM game titles:

Game#1 Game#2 Game#3 Game#4 Game#5

Run-Time

Performance

Improved

3.39%

Improved

1.43%

Improved

9%

Improved

6.11%

Improved

6%

Page 19: Link-Time Optimization - LLVM

Evaluation

Results on some PS4TM game titles:

Game#1 Game#2 Game#3 Game#4 Game#5

Run-Time

Performance

Improved

3.39%

Improved

1.43%

Improved

9%

Improved

6.11%

Improved

6%

• Inliner

• Internalize Global Symbols

• Inter-Procedural Sparse Conditional Constant Propagation

Page 20: Link-Time Optimization - LLVM

Evaluation

Results on some PS4TM game titles:

Game#1 Game#2 Game#3 Game#4 Game#5

Executable

Size

Increased

0.242%

Increased

0.539%

Increased

2%

Decreased

11.8%

Increased

2.06%

Page 21: Link-Time Optimization - LLVM

Evaluation

Results on some PS4TM game titles:

(without debug info)

Game#1 Game#2 Game#3 Game#4 Game#5

Build Time

(LTO vs non-LTO)

4x 3x 5x 2.5x 10x

Page 22: Link-Time Optimization - LLVM

Related Work

Page 23: Link-Time Optimization - LLVM

Related Work

• LTO with debug info: memory usage and build time

Page 24: Link-Time Optimization - LLVM

Related Work

• LTO with debug info: memory usage and build time

• Versioning of bc files

Page 25: Link-Time Optimization - LLVM

Related Work

• LTO with debug info: memory usage and build time

• Versioning of bc files

• Further performance improvement in LTO: • Move some optimization passes from compiler to LTO?

(e.g. loop-unroll, vectorizer)