presenting michal paszkowski research michal paszkowski
play

Presenting: Michal Paszkowski Research: Michal Paszkowski, Radoslaw - PowerPoint PPT Presentation

Presenting: Michal Paszkowski Research: Michal Paszkowski, Radoslaw Drabinski Special thanks to: Julia Koval It is all about the semantic differences! Desired Semantics Instruction order Value names Distracting Basic Block


  1. Presenting: Michal Paszkowski Research: Michal Paszkowski, Radoslaw Drabinski Special thanks to: Julia Koval

  2. It is all about the semantic differences! Desired • Semantics • Instruction order • Value names Distracting • Basic Block names • Redundant code

  3. How could we automate that? We needed a simple tool that would makes comparing semantic differences between two modules easier. The tool should… • ”Reduce” non-semantic differences • Process modules independently • Leverage existing diff tools

  4. How could we automate that? Therefore, the tool should transform a module into a canonical form. How will that “canonical form” help us? • Two semantically identical canonicalized modules should show no differences when diffed. And more importantly… • When the modules are not identical the semantic differences should stand out.

  5. How do we arrive at this canonical form? Let’s start with instruction ordering… Assumptions for comparing an identical module after two different transformations: • Side-Effects should be roughly the same • Control-Flow Graphs should be similar

  6. Instruction reordering %1 = ... %2 = ... • def-use distance reduction %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B %X = fadd float %C, %A store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 ret void

  7. Instruction reordering %1 = ... %2 = ... • def-use distance reduction %T1 = call float @inputV.f32(i32 15, i32 2) 1. Collect instructions with side-effects %A = fsub float %T1, %T1 and ”ret” instructions %B = fmul float %A, %T1 %C = fsub float %T1, %B %X = fadd float %C, %A store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 ret void

  8. Instruction reordering %1 = ... %2 = ... • def-use distance reduction %T1 = call float @inputV.f32(i32 15, i32 2) 1. Collect instructions with side-effects %A = fsub float %T1, %T1 and ”ret” instructions %B = fmul float %A, %T1 2. Walk the instructions with side- %C = fsub float %T1, %B effects (top-down) and on each instruction their operands (left-right) %X = fadd float %C, %A store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 ret void

  9. Instruction reordering %1 = ... %2 = ... • def-use distance reduction %T1 = call float @inputV.f32(i32 15, i32 2) 1. Collect instructions with side-effects %A = fsub float %T1, %T1 and ”ret” instructions %B = fmul float %A, %T1 2. Walk the instructions with side- %C = fsub float %T1, %B effects (top-down) and on each instruction their operands (left-right) %X = fadd float %C, %A 3. For each operand, bring their store float %C, float addrspace(479623)* %1 definition as close as possible to the store float %X, float addrspace(283111)* %2 using instruction ret void

  10. Step-by-step reorder walkthrough %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B %X = fadd float %C, %A store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 ret void

  11. Step-by-step reorder walkthrough %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B Select the 1 st side-effecting instruction. %X = fadd float %C, %A Don’t move it, otherwise semantics may not be preserved! store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  12. Step-by-step reorder walkthrough %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B Take the 1 st operand of the side-effecting instruction. %X = fadd float %C, %A store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  13. Step-by-step reorder walkthrough %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B Move it closer to the user. %X = fadd float %C, %A Def-Use sequence may be temporarily broken. %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  14. Step-by-step reorder walkthrough %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 Select the 1 st operand of the moved instruction. %X = fadd float %C, %A %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  15. Step-by-step reorder walkthrough %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 Move it closer to the user. %X = fadd float %C, %A Def-Use sequence may be temporarily broken. %T1 = call float @inputV.f32(i32 15, i32 2) %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  16. Step-by-step reorder walkthrough %A = fsub float %T1, %T1 %B = fmul float %A, %T1 Select the 2 nd operand of the previously moved instruction. %X = fadd float %C, %A %T1 = call float @inputV.f32(i32 15, i32 2) %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  17. Step-by-step reorder walkthrough %A = fsub float %T1, %T1 %B = fmul float %A, %T1 Move it closer to the user. %X = fadd float %C, %A Def-Use sequence is being repaired. %T1 = call float @inputV.f32(i32 15, i32 2) %B = fmul float %A, %T1 %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  18. Step-by-step reorder walkthrough %A = fsub float %T1, %T1 Select the 1 st operand of the moved instruction. %X = fadd float %C, %A %T1 = call float @inputV.f32(i32 15, i32 2) %B = fmul float %A, %T1 %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  19. Step-by-step reorder walkthrough %A = fsub float %T1, %T1 Move it closer to the user. %X = fadd float %C, %A Def-Use sequence is being repaired. %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  20. Step-by-step reorder walkthrough Select the 1st operand of the moved instruction. Don’t move it! %T1 has been already moved! %X = fadd float %C, %A Select the 2nd operand of the moved instruction. Don’t move it! %T1 has been already moved! %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  21. Step-by-step reorder walkthrough Select the 2 nd operand of the previously moved instruction. %X = fadd float %C, %A Don’t move it, %T1 has been moved before. %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  22. Step-by-step reorder walkthrough We repeat the process for all operands in all side-effecting %X = fadd float %C, %A instructions. %T1 = call float @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %B = fmul float %A, %T1 %C = fsub float %T1, %B store float %C, float addrspace(479623)* %1 store float %X, float addrspace(283111)* %2 Canonicalized instructions ret void

  23. How do we arrive at this canonical form? Desired • Semantics • Instruction order • Value names Distracting • Basic Block names • Redundant code

  24. Naming instructions: Linear • Numbers all instructions top-down after reordering v 𝑜 • We were hoping that maybe the reordering mechanism could be used as a ‘seed’ for instruction naming %T1 = @inputV.f32(i32 15, i32 2) %v0 = @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %v1 = fsub float %v0, %v0 %B = fmul float %A, %T1 %v2 = fmul float %v1, %v0 %C = fsub float %T1, %T1 %v3 = fsub float %v0, %v0 %X = fadd float %C, %A %v4 = fadd float %v3, %v1 store float %C, float addrspace(479623)* %1 store float %v3, float addrspace(479623)* %a3 store float %X, float addrspace(283111)* %2 store float %v4, float addrspace(283111)* %a4 ret void ret void

  25. Naming instructions: Linear • Numbers all instructions top-down after reordering v 𝑜 • We were hoping that maybe the reordering mechanism could be used as a ‘seed’ for instruction naming %T1 = @inputV.f32(i32 15, i32 2) %v0 = @inputV.f32(i32 15, i32 2) %A = fsub float %T1, %T1 %v1 = fsub float %v0, %v0 %B = fmul float %A, %T1 %v2 = fmul float %v1, %v0 %C = fsub float %T1, %T1 %v3 = fsub float %v0, %v0 %X = fadd float %C, %A %v4 = fadd float %v3, %v1 store float %C, float addrspace(479623)* %1 store float %v3, float addrspace(479623)* %a3 store float %X, float addrspace(283111)* %2 store float %v4, float addrspace(283111)* %a4 ret void ret void

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