function merging
play

FUNCTION MERGING by SEQUENCE ALIGNMENT DOES SIZE MATTER? DOES - PowerPoint PPT Presentation

Rodrigo Rocha http://rcor.me University of Edinburgh FUNCTION MERGING by SEQUENCE ALIGNMENT DOES SIZE MATTER? DOES SIZE MATTER? S E Y DOES SIZE MATTER? S E Y ... EMBEDDED SYSTEMS SAVINGS IN CODE Smaller Memories 1 0 1 1 0 1


  1. WHAT WE HAVE Production compilers: LLVM, GCC, MSVC

  2. WHAT WE HAVE Production compilers: LLVM, GCC, MSVC Only Identical Functions

  3. WHAT WE HAVE The state of the art

  4. WHAT WE HAVE The state of the art significant improvement but...

  5. WHAT WE HAVE The state of the art significant improvement but... MUST HAVE IDENTICAL

  6. WHAT WE HAVE The state of the art significant improvement but... MUST HAVE IDENTICAL CFGs

  7. WHAT WE HAVE The state of the art significant improvement but... MUST HAVE IDENTICAL CFGs Return types

  8. WHAT WE HAVE The state of the art significant improvement but... MUST HAVE IDENTICAL CFGs Return types Lists of parameters

  9. WHAT WE HAVE The state of the art significant improvement but... MUST HAVE IDENTICAL CFGs Return types Lists of parameters Number of instructions

  10. WHAT WE WANT

  11. WHAT WE WANT Merge ANY two functions

  12. WHAT WE WANT Merge ANY two functions Merge ANY two functions and CHOOSE when to do it

  13. HOW WE DO IT int f1(int a, int b) { void f2(int a, int b) { int var = a*b + 10; int var = a*b + b; int result = foo(var); int result = foo(var); printf("result: %d\n", result); printf("result: %d\n", result); return result; if (result==0) } printf("result is zero\n"); }

  14. HOW WE DO IT label : entry label : entry IR Level %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) ret %r2 %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  15. HOW WE DO IT label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) ret %r2 %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  16. LINEARIZATION label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) ret %r2 %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  17. LINEARIZATION label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %x1 = add %x0, %b %r1 = add %r0, 10 %x2 = call foo(%x1) %r2 = call foo(%r1) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 %r3 = call printf(@str,%r2) br %x4, %if.then, %if.end ret %r2 label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  18. LINEARIZATION label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %x1 = add %x0, %b %r1 = add %r0, 10 %x2 = call foo(%x1) %r2 = call foo(%r1) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 %r3 = call printf(@str,%r2) br %x4, %if.then, %if.end ret %r2 label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  19. LINEARIZATION label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  20. LINEARIZATION label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  21. LINEARIZATION label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  22. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  23. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  24. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b Match %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  25. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  26. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  27. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b Match %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  28. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b Match %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  29. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b Match %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  30. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  31. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  32. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) Match %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  33. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) Match %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  34. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) Match %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  35. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  36. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo(%r1) %x2 = call foo(%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  37. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  38. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) Match %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  39. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  40. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf(@str,%r2) %x3 = call printf(@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  41. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  42. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  43. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end Mismatch label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  44. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 ret %r2 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  45. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end ret %r2 label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  46. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end ret %r2 label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  47. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end ret %r2 label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  48. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end ret %r2 label : if.then %x5 = call printf(@str) br %if.end label : if.end ret void

  49. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) ret %r2 br %if.end label : if.end ret void

  50. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) ret %r2 br %if.end label : if.end ret void

  51. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) ret %r2 br %if.end label : if.end ret void

  52. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) ret %r2 br %if.end label : if.end ret void

  53. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end ret %r2 label : if.end ret void

  54. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end ret %r2 label : if.end ret void

  55. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret %r2 ret void

  56. IDENTIFY WHAT TO MERGE label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret %r2 ret void

  57. SEQUENCE ALIGNMENT Bioinformatics G C A T - G C U G - A T T A C A

  58. call printf SEQUENCE ALIGNMENT call foo label ret add mul label mul add call foo call printf icmp eq br label call br label ret

  59. call printf Match: +2 SEQUENCE ALIGNMENT Mismatch: -1 call foo Gap: -1 label ret add mul label mul add call foo call printf icmp eq br label call br label ret

  60. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 mul -2 add -3 call foo -4 call printf -5 ret -6

  61. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 mul -2 add -3 call foo -4 call printf -5 ret -6

  62. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 mul -2 add -3 call foo -4 call printf -5 ret -6 -1 -1 = -2

  63. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 mul -2 add -3 call foo -4 call printf -5 ret -6 -1 -1 = -2 -1 -1 = -2

  64. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 mul -2 add -3 call foo -4 call printf -5 ret -6 -1 -1 = -2 -1 -1 = -2 0 + 2 = 2

  65. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 2 mul -2 add -3 call foo -4 call printf -5 ret -6 -1 -1 = -2 -1 -1 = -2 0 + 2 = 2

  66. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 2 mul -2 add -3 call foo -4 call printf -5 ret -6 2 -1 = 1 -2 -1 = -3 -1 -1 = -2

  67. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 2 1 mul -2 add -3 call foo -4 call printf -5 ret -6 2 -1 = 1 -2 -1 = -3 -1 -1 = -2

  68. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 mul -5 -2 1 4 3 2 1 0 -1 -2 -3 -4 -6 add -3 0 3 6 5 4 3 1 0 -1 -3 2 -2 call foo -4 -1 2 5 8 7 6 5 4 3 2 1 0 call printf -5 -2 1 4 7 10 9 8 7 6 5 4 3 ret -6 -3 0 3 6 9 9 8 7 6 5 4 6

  69. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 mul -5 -2 1 4 3 2 1 0 -1 -2 -3 -4 -6 add -3 0 3 6 5 4 3 1 0 -1 -3 2 -2 call foo -4 -1 2 5 8 7 6 5 4 3 2 1 0 call printf -5 -2 1 4 7 10 9 8 7 6 5 4 3 ret -6 -3 0 3 6 9 9 8 7 6 5 4 6

  70. SEQUENCE ALIGNMENT Match: +2 call printf Mismatch: -1 call foo icmp eq Gap: -1 label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 mul -5 -2 1 4 3 2 1 0 -1 -2 -3 -4 -6 add -3 0 3 6 5 4 3 1 0 -1 -3 2 -2 call foo -4 -1 2 5 8 7 6 5 4 3 2 1 0 call printf -5 -2 1 4 7 10 9 8 7 6 5 4 3 ret -6 -3 0 3 6 9 9 8 7 6 5 4 6

  71. SEQUENCE ALIGNMENT call printf call foo icmp eq label label label call mul add ret br br 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 label -1 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 -9 mul -5 -2 1 4 3 2 1 0 -1 -2 -3 -4 -6 add -3 0 3 6 5 4 3 1 0 -1 -3 2 -2 call foo -4 -1 2 5 8 7 6 5 4 3 2 1 0 call printf -5 -2 1 4 7 10 9 8 7 6 5 4 3 ret -6 -3 0 3 6 9 9 8 7 6 5 4 6

  72. CODE GENERATION label : entry label : entry %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret %r2 ret void

  73. CODE GENERATION Renaming Table label: b1 entry b1 %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret %r2 ret void

  74. CODE GENERATION Renaming Table label: b1 entry b1 %r0 = mul %a, %b %x0 = mul %a, %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret %r2 ret void

  75. CODE GENERATION Renaming Table label: b1 entry b1 %m0 = mul %r0 = mul %a , %b %x0 = mul %a , %b %r1 = add %r0, 10 %x1 = add %x0, %b %r2 = call foo (%r1) %x2 = call foo (%x1) %r3 = call printf (@str,%r2) %x3 = call printf (@str,%x2) %x4 = icmp eq %x2, 0 br %x4, %if.then, %if.end label : if.then %x5 = call printf(@str) br %if.end label : if.end ret %r2 ret void

Recommend


More recommend