Understanding Compiler Optimization https://www.youtube.com/watch?v=FnGCDLhaxKU (great talk, Chandler notes 'LLVM does not optimise if UBSan cannot warn on UB')
miniblog.
Related Posts
Using Miri, the Rust interpreter, as a profiler to find bottlenecks: https://medium.com/source-and-buggy/data-driven-performance-optimization-with-rust-and-miri-70cb6dde0d35
"Significant effort has been put into making optimization output agnostic of the -gsetting (so you can rebuild binary with debug info after your program core dumped and use it to debug the core dump)"
Impressive gcc features discussed in
Interprocedural optimization in GCC https://kristerw.blogspot.co.uk/2017/05/interprocedural-optimization-in-gcc.html (overview of some GCC optimisation techniques, along with usage examples)