cpu toolchain launch postmortem - llvm.org · technology – “snc” 2004 prodg psp® ......
TRANSCRIPT
![Page 1: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/1.jpg)
CPU Toolchain Launch Postmortem
Greg Bedwell
![Page 2: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/2.jpg)
x86-64 AMD “Jaguar” 8-core CPU
1.84 TFLOPS AMD Radeon™ based GPU
8GB GDDR5 RAM
![Page 3: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/3.jpg)
http://llvm.org/devmtg/2013-11/
![Page 4: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/4.jpg)
postmortem noun
“an analysis or discussion of an event after it is over”
http://www.merriam-webster.com/dictionary/postmortem
Now that we have successfully launched PlayStation®4 it is a good time to look back on our initial period of development up to
that point
![Page 5: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/5.jpg)
First, some history…
![Page 6: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/6.jpg)
1990 Psy-Q 16-bit home systems
SN Systems Ltd. was founded in 1988 to
provide development tools for the games
industry
![Page 7: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/7.jpg)
1994 Psy-Q PlayStation®
Psy-Q included a version of GCC that was highly
customized for the needs of game
developers
![Page 8: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/8.jpg)
2000 ProDG PlayStation®2
Continued to provide GCC but started
researching a proprietary compiler technology – “SNC”
![Page 9: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/9.jpg)
2004 ProDG PSP® (PlayStation®Portable)
Provided SNC as part of the ProDG suite of tools although GCC was also
available
![Page 10: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/10.jpg)
2006 ProDG PlayStation®3
Sony Computer Entertainment Inc.
acquired SN Systems in 2005
Provided SNC as part of the ProDG suite of tools although GCC was also
available
![Page 11: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/11.jpg)
2011
PlayStation®Vita
CPU Compiler is SNC
![Page 12: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/12.jpg)
2013 PlayStation®4
CPU Compiler is Clang
![Page 13: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/13.jpg)
The CPU compiler project is a global effort
![Page 14: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/14.jpg)
Builds and build systems (and test systems)
![Page 15: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/15.jpg)
We wanted to make use of all of our pre-existing
test suites and test systems, which are
shared across all targets
![Page 16: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/16.jpg)
![Page 17: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/17.jpg)
Optimized Assertions Debug Info
Debug
MinSizeRel
Release
RelWithDebInfo
![Page 18: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/18.jpg)
Optimized Assertions Debug Info
Debug
MinSizeRel
Release
RelWithDebInfo
![Page 19: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/19.jpg)
2h 41m 24s
12m 56s 7m 44s
0
2000
4000
6000
8000
10000
12000
Debug Release+Asserts Release
seco
nd
s
Clang configuration effect on game build time
Too slow for continuous integration testing!
Useful for continuous integration testing but
still too much overhead over the pure release configuration of clang
![Page 20: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/20.jpg)
Optimized Assertions Debug Info
Debug
Checking
Release
The same set of build configurations as we use
for SNC
“Debug” for debugging
“Release” for releasing
“Checking” (Release+Asserts) for
continuous integration testing
![Page 21: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/21.jpg)
Optimized Assertions Debug Info
Debug
Checking
Release
O
![Page 22: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/22.jpg)
0
5
10
15
20
25
30
35
40
45
Default /Zi (Produce PDB) /Zi (Produce PDB) and /OPT:REF /OPT:REF
clan
g.ex
e s
ize
(M
B)
No executable size overhead for enabling
debug data
![Page 23: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/23.jpg)
Optimized Assertions Debug Info
Debug
Checking
Release
O
![Page 24: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/24.jpg)
Optimized Assertions Debug Info
Debug
Checking
Release
Suppress Windows crash dialog box for
Checking and Release builds
![Page 25: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/25.jpg)
Improving test coverage
![Page 26: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/26.jpg)
Game code is usually
BIG For a new platform, the amount of code that exists is small
Things we
know
![Page 27: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/27.jpg)
Users value
CORRECTNESS over all else
Things we
know
![Page 28: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/28.jpg)
Why write tests
when I can write a test generator?
![Page 29: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/29.jpg)
Why write tests
when I can write a test generator? already have _
![Page 30: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/30.jpg)
Random input
Result
Generate random C++ tests using SIMD
language extensions and intrinsics to increase test
coverage
![Page 31: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/31.jpg)
Result
Random input
![Page 32: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/32.jpg)
Result
Random input
![Page 33: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/33.jpg)
Result Random
input
![Page 34: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/34.jpg)
Result Random
input
![Page 35: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/35.jpg)
Result Random
input
![Page 36: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/36.jpg)
Result Random
input
Undefined behaviour makes runtime-
behaviour random testing hard!
![Page 37: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/37.jpg)
Result Random
input
Solution: Use a ‘safe’ wrapper to make all undefined behaviour
defined for the purpose of the test
![Page 38: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/38.jpg)
Reducing optimization bugs
![Page 39: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/39.jpg)
bugpoint
Clang integration
Windows
![Page 40: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/40.jpg)
An alternative approach
![Page 41: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/41.jpg)
*Not representative of actual visuals
SNC’s max_opts
![Page 42: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/42.jpg)
![Page 43: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/43.jpg)
SNC’s max_opts
![Page 44: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/44.jpg)
SNC’s max_opts
![Page 45: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/45.jpg)
SNC’s max_opts
![Page 46: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/46.jpg)
SNC’s max_opts
![Page 47: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/47.jpg)
SNC’s max_opts
![Page 48: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/48.jpg)
SNC optimizer
SSA Form Rule Based
Every transformation is guarded
by a specific check
SNC’s max_opts
![Page 49: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/49.jpg)
SNC keeps an internal counter of the number of transformations
it performs
Allows the user to specify a limit on the command line after which no further
transformations can be performed
![Page 50: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/50.jpg)
“Autochop” harness SNC’s
max_opts -O2
![Page 51: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/51.jpg)
“Autochop” harness SNC’s
max_opts -O0
![Page 52: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/52.jpg)
“Autochop” harness SNC’s
max_opts -O0
-O2
![Page 53: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/53.jpg)
“Autochop” harness SNC’s
max_opts -O0
-O2
![Page 54: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/54.jpg)
“Autochop” harness SNC’s
max_opts -O0
-O2
![Page 55: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/55.jpg)
“Autochop” harness SNC’s
max_opts We’ve found the game source file
with the bad transformation
![Page 56: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/56.jpg)
“Autochop” harness SNC’s
max_opts -Xmax_opts=2048
![Page 57: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/57.jpg)
“Autochop” harness SNC’s
max_opts -Xmax_opts=1024
![Page 58: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/58.jpg)
“Autochop” harness SNC’s
max_opts -Xmax_opts=512
![Page 59: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/59.jpg)
“Autochop” harness SNC’s
max_opts -Xmax_opts=988
![Page 60: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/60.jpg)
“Autochop” harness SNC’s
max_opts -Xmax_opts=989
Now we’ve found the specific transformation causing the miscompile
![Page 61: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/61.jpg)
A compiler trace shows us the culprit optimization
![Page 62: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/62.jpg)
Narrowed down to a single difference in IR
Just a single line change in the IR
![Page 63: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/63.jpg)
A question for the community:
SNC’s max_opts Would this work in
LLVM/Clang? (even if just at pass level)
![Page 64: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/64.jpg)
The release process
![Page 65: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/65.jpg)
Docs
End-user documentation is lacking
Release notes aimed at Clang/LLVM developers, not users
![Page 66: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/66.jpg)
Docs
We plan to contribute our documentation improvements to the community
![Page 67: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/67.jpg)
Docs
We plan to contribute our documentation improvements to the community
![Page 68: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/68.jpg)
Forward compatibility
![Page 69: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/69.jpg)
ABI System libraries
v3.x v3.x
![Page 70: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/70.jpg)
ABI v3.x
System libraries
v4.x
![Page 71: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/71.jpg)
ABI v3.x v5.x
System libraries
![Page 72: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/72.jpg)
ABI v3.x v6.x
System libraries
![Page 73: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/73.jpg)
ABI v3.x v13.x
System libraries
![Page 74: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/74.jpg)
ABI
Maintaining a stable ABI is a
MUST (including maintaining existing ABI bugs)
![Page 75: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/75.jpg)
We have created a full IA64 ABI test suite
![Page 76: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/76.jpg)
ABI TEST
SUITE
We hope to contribute our test suite to the community
(some logistics still to be worked out)
![Page 77: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/77.jpg)
Developer reaction
![Page 78: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/78.jpg)
![Page 79: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/79.jpg)
But…
![Page 80: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/80.jpg)
#pragma optimize
Most requested feature by an
order of magnitude and already supported by all the other major compilers
![Page 81: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/81.jpg)
#pragma optimize
This is the most common
use-case:
Game runs too slowly at –O0,
but is very hard to debug
at –O2
![Page 82: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/82.jpg)
#pragma optimize
Solution: use a pragma to selectively disable optimization
on a small set of functions to be
debugged
We proposed this on the mailing lists, but it is a major change and we got a limited response
![Page 83: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/83.jpg)
#pragma optimize
Short term solution: function level attribute to disable
optimization
Not user-friendly for more than a very small number of
functions at a time!
![Page 84: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/84.jpg)
#pragma optimize
Many of our users abstract this away behind a compiler-
independent interface. Function
attribute does not fit this model!
We still need a range-based solution
![Page 85: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/85.jpg)
In summary
![Page 86: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/86.jpg)
Thanks to all of you who helped make Clang and
LLVM great!
Our initial experience with Clang and LLVM has been very positive
![Page 87: CPU Toolchain Launch Postmortem - llvm.org · technology – “SNC” 2004 ProDG PSP® ... max_opts -Xmax_opts=989 Now we’ve found the specific transformation causing the miscompile](https://reader031.vdocuments.mx/reader031/viewer/2022022601/5b4c52f07f8b9afe4d8b8799/html5/thumbnails/87.jpg)
There are still improvements
that can be made…
We will be working alongside you to make them