Randomized Stress-Testing of Link-Time Optimizers Vu Le, Chengnian - - PowerPoint PPT Presentation

randomized stress testing of link time optimizers
SMART_READER_LITE
LIVE PREVIEW

Randomized Stress-Testing of Link-Time Optimizers Vu Le, Chengnian - - PowerPoint PPT Presentation

Randomized Stress-Testing of Link-Time Optimizers Vu Le, Chengnian Sun , Zhendong Su University of California, Davis 1 7/15/2015 General Software Build Process Compiler Linker 2 7/15/2015 General Software Build Process Compiler


slide-1
SLIDE 1

Randomized Stress-Testing of Link-Time Optimizers

Vu Le, Chengnian Sun, Zhendong Su University of California, Davis

7/15/2015 1

slide-2
SLIDE 2

General Software Build Process

Linker Compiler

7/15/2015 2

slide-3
SLIDE 3

General Software Build Process

Linker

Compiler

 Compiler Optimizations

 Intra-procedural, within a function  Inter-procedural, across functions  Whole-program, over all the functions

 Optimizing a translation unit (*.c),

 Intra-procedural  Inter-procedural? Limited to the unit  Whole-program? Usually NO.

7/15/2015 3

slide-4
SLIDE 4

General Software Build Process

Linker

Compiler

 How to perform

 More aggressive inter-procedural opts?  Or even whole-program opts?

7/15/2015 4

slide-5
SLIDE 5

General Software Build Process

Linker

Compiler

 How to perform

 More aggressive inter-procedural opts?  Or even whole-program opts?

(LTO)Link-Time Optimizer

7/15/2015 5

slide-6
SLIDE 6

General Software Build Process

Linker Compiler

7/15/2015 6

slide-7
SLIDE 7

Software Build Process with LTO (-flto)

Linker -flto Compiler -flto save intermediate representation (IR) to *.obj read all IR back and optimize

7/15/2015 7

slide-8
SLIDE 8

Motivation – Stress Testing LTO

 LTO is increasingly important [1,2]

 Reduce code size by 15-20%  Increase speed by 5-15%

 No effort yet on stress testing LTO

 Csmith [3] and Orion [4] focus on classical optimizers

7/15/2015 8

[1] B. Anckaert, F. Vandeputte, B. Bus, B. Sutter, and K. Bosschere. Link-Time Optimization of IA64 Binaries. In M. Danelutto, M. Vanneschi, and D. Laforenza, editors, Euro-Par 2004 Parallel Processing [2] B. De Sutter, L. Van Put, D. Chanet, B. De Bus, and K. De Bosschere. Link-Time Compaction and Optimization

  • f Arm Executables. ACM Trans. Embed. Comput. Syst 2007

[3] X. Yang, Y. Chen, E. Eide, and J. Regehr. Finding and understanding bugs in C compilers. PLDI 2011 [4] V. Le, M. Afshari, and Z. Su. Compiler validation via equivalence modulo inputs. PLDI 2014

slide-9
SLIDE 9

Challenges

 How to generate LTO-relevant test programs?

 Csmith and Orion generate single-file test programs

 How to reduce bug-triggering test programs?

 Delta and Creduce, designed for single-file tests

7/15/2015 9

slide-10
SLIDE 10

Overall Framework – Differential Testing

7/15/2015 10

Random Program Build Config. Compare Split Files Compile (no LTO) Compile (LTO) Compile (LTO) Execute Execute Execute Reduce

slide-11
SLIDE 11

Overall Framework – Differential Testing

7/15/2015 11

Random Program Build Config. Compare Split Files Compile (no LTO) Compile (LTO) Compile (LTO) Execute Execute Execute Reduce

slide-12
SLIDE 12

Overall Framework – Differential Testing

7/15/2015 12

Random Program Build Config. Compare Split Files Compile (no LTO) Compile (LTO) Compile (LTO) Execute Execute Execute Reduce

slide-13
SLIDE 13

Overall Framework – Differential Testing

7/15/2015 13

Random Program Build Config. Compare Split Files Compile (no LTO) Compile (LTO) Compile (LTO) Execute Execute Execute Reduce

slide-14
SLIDE 14

Overall Framework – Differential Testing

7/15/2015 14

Random Program Build Config. Compare Split Files Compile (no LTO) Compile (LTO) Compile (LTO) Execute Execute Execute Reduce

slide-15
SLIDE 15

Challenge I – Program Generation

7/15/2015 15

 Leverage existing program generators  Convert a sin

ingle le-file test to mult ltiple iple files

 Maximize the dependencies between source files

slide-16
SLIDE 16

Challenge I – Program Generation (1)

7/15/2015 16

Csmith: Generate a random single-file program with Csmith

Prog

slide-17
SLIDE 17

Challenge I – Program Generation (2)

7/15/2015 17

Csmith: Generate a random single-file program with Csmith Orion: Inject arbitrary function calls into dead code regions, to complicate inter-dependencies

Prog Orion

Prog’

slide-18
SLIDE 18

Challenge I – Program Generation (3)

7/15/2015 18

Csmith: Generate a random single-file program with Csmith Orion: Inject arbitrary function calls into dead code regions, to complicate inter-dependencies Split: Split the single-file program into multiple files, each file containing one function

Prog Orion

Prog’

Split

Compiler -flto Linker -flto

slide-19
SLIDE 19

Challenge I – Build Configurations

7/15/2015 19

 Describe at which optimization level

 a translation unit should be compiled  all object files should be linked

 Random configurations can further exercise LTO

 Opt as obfuscators

Compiler -flto Linker -flto

slide-20
SLIDE 20

Challenge I – An Example

7/15/2015 20

expected output: 0

slide-21
SLIDE 21

Challenge I – An Example

7/15/2015 21

expected output: 0

slide-22
SLIDE 22

Challenge I – An Example

7/15/2015 22

expected output: 0

slide-23
SLIDE 23

Challenge I – An Example

7/15/2015 23

expected output: 0

slide-24
SLIDE 24

Challenge I – An Example

7/15/2015 24

expected output: 0

slide-25
SLIDE 25

Challenge I – An Example

7/15/2015 25

expected output: 0 real output : 1

slide-26
SLIDE 26

Challenge II – Reducing Test Programs

7/15/2015 26

 Reducing multiple files is challenging

 Interdependencies between translation units  Avoiding undefined behaviors (CompCert)

Delta/Creduce

slide-27
SLIDE 27

Challenge II – Reducing Test Programs

7/15/2015 27

 Reducing multiple files is challenging

 Interdependencies between translation units  Avoiding introducing undefined behaviors

 Instead, we reduce the single-file test program

Prog’

Split

Compiler -flto Linker -flto

slide-28
SLIDE 28

Evaluation

7/15/2015 28

 Two multi-core Ubuntu machines  February 2014 – Janurary 2015  37 valid bug reports to GCC and LLVM (11 fixed)

slide-29
SLIDE 29

Bug Classification

7/15/2015 29

GCC LLVM Total Wrong code 6 (5 fixed) 22 (0 fixed) 28 Crash 5 (5 fixed) 5 Linker Error 1 (1 fixed) 3 (0 fixed) 4

slide-30
SLIDE 30

Conclusion

7/15/2015 30

 the first effort to stress-test LTO  transformation way to generate test programs  an effective technique to reduce LTO bugs  11 months, 37 valid bugs in GCC and LLVM

slide-31
SLIDE 31

7/15/2015 31

Overall Framework – Differential Testing

7/13/2015 10

Random Program Build Config. Compare Split Files Compile (no LTO) Compile (LTO) Compile (LTO) Execute Execute Execute Reduce

Challenge I – Program Generation (3)

7/13/2015 18

Csmith: Generate a random single-file program with Csmith Orion: Inject arbitrary function calls into dead code regions, to complicate inter-dependencies Split: Split the single-file program into multiple files, each file containing one function

Prog Orion

Prog’

Split

Compiler -flto Linker -flto

Challenge II – Reducing Test Programs

7/13/2015 27

 Reducing multiple files is challenging

 Interdependencies between translation units  Avoiding introducing undefined behaviors

 Instead, we reduce the single-file test program

Prog’

Split

Compiler -flto Linker -flto

Bug Classification

7/15/2015 29

GCC LLVM Total Wrong code 6 (5 fixed) 22 (0 fixed) 28 Crash 5 (5 fixed) 5 Linker Error 1 (1 fixed) 3 (0 fixed) 4