140 likes | 383 Views
Debugging Optimized Code. Steven Osman. Debugging Optimized Code is Hard …. Un-optimized code has a correlation between source and object code Optimizing compilers rearrange, add and remove code. This results in: Code location problems Data value problems. Talk Overview.
E N D
Debugging Optimized Code Steven Osman
Debugging Optimized Code is Hard… • Un-optimized code has a correlation between source and object code • Optimizing compilers rearrange, add and remove code. This results in: • Code location problems • Data value problems
Talk Overview • Understanding the problems • Introducing Source-Level Debugging of Scalar Optimized Code • Classifying data-value problems • Identifying data-value problems • What’s next?
The Code Location Problem We want a breakpoint at S2
The Data-Value Problem What is the value of y at S2?
Source-Level Debugging of Scalar Optimized Code • By Ali-Reza Adl-Tabatabai and Thomas Gross • Identifies data-value problems • No changes to the optimized code • Uses knowledge of optimizations
Some Simple Terminology • Expected value = value a variable should have • Actual value = value stored in register • Current = Actual value IS expected value (true for all in unoptimzed code) • Endangered = Not current • Noncurrent = Actual IS NOT expected • Suspect = Actual may be expected
Code Hoisting E0: x=u-v E1: x=y+z Bkpt1 Bkpt2 E2: x=y+z Bkpt3
Code Hoisting E0: x=u-v E1: x=y+z E3: x=y+z Bkpt1 Bkpt2 E2: x=y+z Bkpt3 E2=RedCopy(E3)
Hoist Reaches E0: x=u-v E1: x=y+z E3: x=y+z Bkpt1 Bkpt2 E2: x=y+z Bkpt3 E2=RedCopy(E3)
Dead Code Elimination E0: x=y+z Bkpt1 Bkpt3 E1: …=x Bkpt4 Bkpt2 Bkpt5 E2: x=u-v Bkpt6
Dead Code Elimination E0: x=y+z Bkpt1 Bkpt3 E3: x=y+z E1: …=x Bkpt4 Bkpt2 Bkpt5 E2: x=u-v Bkpt6
Dead Reaching E0: x=y+z Bkpt1 Bkpt3 E3: x=y+z E1: …=x Bkpt4 Bkpt2 Bkpt5 E2: x=u-v Bkpt6
What’s Next? • Good paper, but it only warns programmer • Suggestions about how to get the expected value • Alok Ladsariya’s talk…