際際滷

際際滷Share a Scribd company logo
WHAT EVERY C++ PROGRAMMER SHOULD
KNOW ABOUT MODERN COMPILERS
SAWOMIR ZBOROWSKI
ACCU 2016, BRISTOL, UK
SAWEK ZBOROWSKI
WROCAW, POLAND
OUTLINE
overview
architecture, inputs, targets
standard, compilers and reality
undefined behavior
optimizations
outsmarting compiler
ecosystem
tooling, further optimizations
OUTLINE
overview
architecture, inputs, targets
standard, compilers and reality
undefined behavior
optimizations
outsmarting compiler
ecosystem
tooling, further optimizations
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
h t t p : / / l e a n i n g t e c h . c o m / c h e e r p /
ARCHITECTURE OVERVIEW
h t t p s : / / d e v h u m o r . c o m / c o n t e n t / u p l o a d s / / i m a g e s / O c t o b e r 2 0 1 5 / F r o n t - e n d - x - B a c k - e n d . j p g
FLAGS
Newbie -o
Junior -c, -Wl,-shared, -Wl,-static, 
Average -Wall, -Wextra, -Werror, -O2, 
Expert -finline-limit, -ftemplate-depth, 
Ninja -B, -nostdlib,
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
OUTLINE
overview
architecture, inputs, targets
standard, compilers and reality
undefined behavior
optimizations
outsmarting compiler
ecosystem
tooling, further optimizations
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
h t t p : / / c o m m u n i t y . f a n s s h a r e . c o m / p i c 1 0 8 / w / t r a d u c i a n i s m / 1 2 0 0 / 1 7 5 2 _ c a u t i o n _ t h i s _ i s _ s p a r t a _ j e x . j p g
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
h t t p : / / f a c s t a f f . c b u . e d u / s e i s e n / C a d F a 0 9 1 3 _ f i l e s / i m a g e 0 3 2 . j p g
UNDEFINED
BEHAVIOR
SANITIZER
h t t p s : / / w w w . y o u t u b e . c o m / w a t c h ? v = H f - z n K i V w y k
OUTLINE
overview
architecture, inputs, targets
standard, compilers and reality
undefined behavior
optimizations
outsmarting compiler
ecosystem
tooling, further optimizations
OPTIMIZATIONS
OUTSMARTING COMPILER
1 auto tmp = a;
2 a = b;
3 b = tmp;
1 a ^= b;
2 b ^= a;
3 a ^= b;
h t t p s : / / w w w . y o u t u b e . c o m / w a t c h ? v = b S 5 P _ L A q i V g
What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)
COMPILER'S KNOWLEDGE
CPU CACHES
CPU EXTENSIONS
CPU PERFORMANCE BUGS
INSTRUCTION SIZES (IN BINARY)
OUTLINE
overview
architecture, inputs, targets
standard, compilers and reality
undefined behavior
optimizations
outsmarting compiler
ecosystem
tooling, further optimizations
INSTRUMENTALIZATION
ADDRESS SANITIZER
MEMORY SANITIZER
CONTROL FLOW SANITIZER
THREAD SANITIZER
EFFICIENCY SANITIZER

h t t p s : / / b o u r n e t o c o d e . c o m / p r o j e c t s / G C S E _ C o m p u t i n g _ F u n d a m e n t a l s / p a g e s / i m g / R A M . j p g
h t t p : / / c r e a t e . p r o / b l o g / w p - c o n t e n t / u p l o a d s / 2 0 1 4 / 1 2 / M a c - P r o - M u l t i - C o r e - P r o c e s s o r - 3 -
e 1 4 1 8 6 5 8 6 8 9 8 7 8 . j p g
CLANG TOOLS
CLANG-FORMAT
CLANG-TIDY
CLANG-COMPLETE
CLANG-ANALYZER

h t t p s : / / u p l o a d . w i k i m e d i a . o r g / w i k i p e d i a / e n / 4 / 4 c / L L V M _ L o g o . s v g
TEMPLIGHT / TEMPLATOR
h t t p s : / / g i t h u b . c o m / m i k a e l - s - p e r s s o n / t e m p l i g h t - t o o l s
SYNTH
STOKE
Stochastic optimizer (x86_64)
THANKS!!

More Related Content

What every C++ programmer should know about modern compilers (w/o comments, ACCU 2016)