of optimized code
play

of optimized code Michael Ernst University of Washington (work - PowerPoint PPT Presentation

Practical fine-grained static slicing of optimized code Michael Ernst University of Washington (work done at Microsoft Research) Ernst Slicing 5/97 Page 1 Simple example Ernst Slicing 5/97 Page 2 Example: function calls and pointers Ernst


  1. Practical fine-grained static slicing of optimized code Michael Ernst University of Washington (work done at Microsoft Research) Ernst Slicing 5/97 Page 1

  2. Simple example Ernst Slicing 5/97 Page 2

  3. Example: function calls and pointers Ernst Slicing 5/97 Page 3

  4. Applications of slicing Closure slicing: visualize dependences  program understanding  maintenance  test coverage  debugging Executable slicing: produce binary  specialization  parallelization  testing  integration of program versions Dynamic slicing: execution tracing Ernst Slicing 5/97 Page 4

  5. Outline Motivation Basic slicing algorithm Interprocedural Pointers and aggregate values Optimized code Executable slicing Conclusion Ernst Slicing 5/97 Page 5

  6. Simple slicing algorithm For graph-based program representation: Just graph reachability! Ernst Slicing 5/97 Page 6

  7. The value dependence graph (VDG) Sparse, functional, parallel representation for imperative programs Insights:  Only values matter  Original names and control flow are incidental Consequences:  All values are explicit  Select values, not control paths  Control flow represented by function calls Ernst Slicing 5/97 Page 7

  8. Components of the value dependence graph operation nodes + 5 selectors  closures (functions) + function calls Call x memory lookups (load instructions) Update x Store memory assignments (store instructions) Ernst Slicing 5/97 Page 8

  9. Example VDG n I/O i sum product 0 1 + Call + * < " Sum ..." Call printf void sum_product(int n)  {  int sum = 0; Call int product = 0; int i = 0; sum product I/O while (i++ < n) { sum = sum + i; product = product * i; } printf("Sum %d, product %d", sum, product); } Ernst Slicing 5/97 Page 9

  10. Example VDG, sliced n I/O i sum product 0 1 + Call + * < " Sum ..." Call printf   Call sum product I/O Ernst Slicing 5/97 Page 10

  11. The VDG is good for slicing  Simple, fast algorithm  Fine granularity  One graph directly links producers and consumers  All values are explicit Ernst Slicing 5/97 Page 11

  12. Slicing criteria Expression results, not whole computations Any expression Any result, including unnameable ones Unreferenced variables Ernst Slicing 5/97 Page 12

  13. Outline Motivation Basic slicing algorithm Interprocedural Pointers and aggregate values Optimized code Executable slicing Conclusion Ernst Slicing 5/97 Page 13

  14. Interprocedural slicing Goals:  sensitive to calling context  do not include entire procedure or all calls  efficient  omit irrelevant procedures Obvious solution: graph reachability  call results  procedure returns  formal parameters  actual parameters This does not satisfy our goals. Ernst Slicing 5/97 Page 14

  15. Interprocedural slicing (solution)  Summarize dependences of returns on formals  Separately include appropriate portions of body  When slicing criterion is within a procedure, include all calls This meets our goals. Ernst Slicing 5/97 Page 15

  16. Procedure summary dependences Optimistic forward dataflow problem  operation result depends on what the operands depend on  for calls, use current approximation as transfer function  reprocess calls when new approximation becomes available  iterate until fixpoint is reached Complexity Ernst Slicing 5/97 Page 16

  17. Outline Motivation Basic slicing algorithm Interprocedural Pointers and aggregate values Optimized code Executable slicing Conclusion Ernst Slicing 5/97 Page 17

  18. Pointers Support arbitrary pointer manipulations Points-to analysis gives possibly referenced locations For lookup, slice on location and (part of) store ...x... x store ...*x... store x store Lookup = x Lookup Lookup Ernst Slicing 5/97 Page 18

  19. Treat store as a collection Slice on every possibly referenced location. store store x 22 a Lookup Update store Slice continues at  killing def: location, value (use pointer equality)  preserving def: location, value, store  other: store Ernst Slicing 5/97 Page 19

  20. Aggregate values Just like the store. Complexity Ernst Slicing 5/97 Page 20

  21. Outline Motivation Basic slicing algorithm Interprocedural Pointers and aggregate values Optimized code Executable slicing Conclusion Ernst Slicing 5/97 Page 21

  22. Slicing optimized code Improve:  dependences  liveness  computations  overhead The hardware runs optimized code Slice reflects intermediate representation’s semantics Ernst Slicing 5/97 Page 22

  23. Correspondence with source code Need many-to-many mappings  VDG node  source text  source text  VDG node Maintain a separate source graph  initially isomorphic to VDG  transformations modify VDG and source correspondences  slicing traverses both graphs in tandem  slice display defaultly highlights only appropriate sources Ernst Slicing 5/97 Page 23

  24. History mechanism Source graphs are never side-effected or removed Transformations add to source graph Mappings no longer necessarily inverses This enables  undoing transformations  explaining changes  slice according to naive interpretation  slice dead code  statement-oriented display Ernst Slicing 5/97 Page 24

  25. Outline Motivation Basic slicing algorithm Interprocedural Pointers and aggregate values Optimized code Executable slicing Conclusion Ernst Slicing 5/97 Page 25

  26. Executable slicing Goal: executable binary Applications:  specialization  parallelization  testing  integration of program versions Ernst Slicing 5/97 Page 26

  27. Compilable slicing Traditional technique for executable slicing:  subset the original program  compile using a standard compiler Ernst Slicing 5/97 Page 27

  28. Compilable slicing tradeoffs Retains context, comments, formatting, names Include undemanded portions of the program to satisfy syntactic constraints  multi-valued computation  function call parameters  variable assignments  control flow: goto , continue , break Limits optimization Hard to undo Ernst Slicing 5/97 Page 28

  29. Our executable slicing solution Generate code directly from slice For debugging, use original program 10110 Ernst Slicing 5/97 Page 29

  30. Outline Motivation Basic slicing algorithm Interprocedural Pointers and aggregate values Optimized code Executable slicing Conclusion Ernst Slicing 5/97 Page 30

  31. Status Part of a programming environment Handles C (except longjmp ) Written in Scheme Integrated with Emacs Ernst Slicing 5/97 Page 31

  32. Future work Quasi-static slicing Dynamic slicing History mechanism User interface alternatives Tests on real users Debugging optimized code Ernst Slicing 5/97 Page 32

  33. Ambiguity in program points z = ...; store a = b + c; z = x * y; b c + a store (a,b,c) store (x,y,z) Update b c x y x y + + + a z z Update Update Update store (a,b,c) store (x,y,z) store Ernst Slicing 5/97 Page 33

  34. Comparing the VDG and PDG Which PDG? VDG:  no implicit quantities  better integration with programming environment  easier analysis, transformation  cleaner interprocedural representation  single graph  finer granularity Ernst Slicing 5/97 Page 34

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend