The Phoenix Compiler and Tools Framework

Slides:



Advertisements
Similar presentations
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
Advertisements

Control-Flow Graphs & Dataflow Analysis CS153: Compilers Greg Morrisett.
The OpenUH Compiler: A Community Resource Barbara Chapman University of Houston March, 2007 High Performance Computing and Tools Group
Phoenix: a framework for Code Generation, Optimization and Program Analysis Andrew Pardoe Phoenix team
Advanced Compiler Design CSE 231 Instructor: Sorin Lerner.
Components of representation Control dependencies: sequencing of operations –evaluation of if & then –side-effects of statements occur in right order Data.
Program Representations. Representing programs Goals.
Automated creation of verification models for C-programs Yury Yusupov Saint-Petersburg State Polytechnic University The Second Spring Young Researchers.
ACM Southeast Conference Melbourne, FL March 11, 2006 Phoenix-Based Clone Detection using Suffix Trees Robert Tairas
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
6/9/2015© Hal Perkins & UW CSEU-1 CSE P 501 – Compilers SSA Hal Perkins Winter 2008.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
The Microsoft View: Module 1: Getting Started. Copyright Course 2559B, Introduction to Visual Basic®.NET Programming with Microsoft®.NET. Lecture 1 Microsoft.
Representing programs Goals. Representing programs Primary goals –analysis is easy and effective just a few cases to handle directly link related things.
Cpeg421-08S/final-review1 Course Review Tom St. John.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
From last time: live variables Set D = 2 Vars Lattice: (D, v, ?, >, t, u ) = (2 Vars, µ, ;,Vars, [, Å ) x := y op z in out F x := y op z (out) = out –
Advanced Compilers CSE 231 Instructor: Sorin Lerner.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
Combining Static and Dynamic Data in Code Visualization David Eng Sable Research Group, McGill University PASTE 2002 Charleston, South Carolina November.
Class canceled next Tuesday. Recap: Components of IR Control dependencies: sequencing of operations –evaluation of if & then –side-effects of statements.
Software Optimization and Analysis Framework Phoenix By Joel Messer.
Code Generation Compiler Baojian Hua
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Recap from last time: live variables x := 5 y := x + 2 x := x + 1 y := x y...
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Building An Interpreter After having done all of the analysis, it’s possible to run the program directly rather than compile it … and it may be worth it.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
An external perspective.  Matt Miller  Consultant with Leviathan Security Group  Core developer for the Metasploit Framework  Uninformed Journal editor.
LLVM Developed by University of Illinois at Urbana-Champaign CIS dept Cisc 471 Matthew Warner.
Precision Going back to constant prop, in what cases would we lose precision?
Introduction 01_intro.ppt
Using Microsoft Phoenix in Education and Research Dragan Bojić University of Belgrade
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
AutoHacking with Phoenix Enabled Data Flow Analysis Richard Johnson |
McLab Tutorial Part 6 – Introduction to the McLab Backends MATLAB-to-MATLAB MATLAB-to-Fortran90 (McFor) McVM with JIT 6/4/2011Backends-
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Andy Ayers Microsoft VC++
Phoenix John LeforShahrokh Mortazavi Microsoft ResearchDeveloper Division.
ICD-C Compiler Framework Dr. Heiko Falk  H. Falk, ICD/ES, 2008 ICD-C Compiler Framework 1.Highlights and Features 2.Basic Concepts 3.Extensions.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 10, 10/30/2003 Prof. Roy Levow.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
Java Virtual Machine Case Study on the Design of JikesRVM.
Architecture for a Next-Generation GCC Chris Lattner Vikram Adve The First Annual GCC Developers'
Type Systems CS Definitions Program analysis Discovering facts about programs. Dynamic analysis Program analysis by using program executions.
Joe Hummel, the compiler is at your service Chicago Code Camp 2014.
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
1 Optimizing compiler tools and building blocks project Alexander Drozdov, PhD Sergey Novikov, PhD.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Overview of Compilers and JikesRVM John.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
Contents : What is Silverlight? Silverlight Overview Silverlight Toolkit Overview Timeline & Packaging Silverlight V1.0 & V1.1 Properties of V1.0 Properties.
Demo of Scalable Pluggable Types Michael Ernst MIT Dagstuhl Seminar “Scalable Program Analysis” April 17, 2008.
Chuck Mitchell Senior Architect, Phoenix Product Unit Microsoft Corporation.
Program Representations. Representing programs Goals.
Building on Phoenix Michael D. Smith Harvard University © Copyright by Michael D. Smith 2005 All rights reserved.
Hy-C A Compiler Retargetable for Single-Chip Heterogeneous Multiprocessors Philip Sweany 8/27/2010.
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
Advanced Compiler Design
Workshop in Nihzny Novgorod State University Activity Report
CMPE419 Mobile Application Development
2.1. Compilers and Interpreters
Feedback directed optimization in Compaq’s compilation tools for Alpha
CSE401 Introduction to Compiler Construction
Advanced Compiler Design
The SGI Pro64 Compiler Infrastructure
CMPE419 Mobile Application Development
Running C# in the browser
Topic 2b ISA Support for High-Level Languages
Presentation transcript:

The Phoenix Compiler and Tools Framework Andy Ayers Microsoft Phoenix AndyA@microsoft.com

What is Phoenix? Phoenix is a codename for Microsoft’s next-generation, state of the art infrastructure for program analysis and transformation

Why Phoenix? VS

Phoenix Goals An industry leading compilation and tools framework A rich ecosystem for academic research and industrial users An infrastructure that is robust retargetable extensible configurable scalable

Overview Phoenix AST Tools .Net CodeGen MSR Adv Lang Native CodeGen Static Analysis Tools Next Gen Front-Ends R/W Global Program Views MSR Adv Lang Runtime JITs Pre-JIT OO and .Net optimizations Language Research Direct xfer to Phoenix Research Insulated from code generation Phoenix Infrastructure Native CodeGen MSR & Partner Tools Advanced C++/OO Optimizations FP optimizations OpenMP Built on Phoenix API’s Both HL and LL API’s Managed API’s Program Analysis Program Rewrite Academic RDK Retargetable Managed API’s IP as DLLs Docs “Machine Models” ~3 months: -Od ~3 months: -O2 Chip Vendor CDK ~6 month ports Sample port + docs

AST IR Syms Types CFG SSA Compilers Tools Browser Visualizer Lint HL Opts HL Opts HL Opts LL Opts LL Opts LL Opts Code Gen Code Gen Formatter Obfuscator Refactor Xlator Profiler Security Checker Phx APIs Phoenix Core AST IR Syms Types CFG SSA assembly Native Image C++ IL PreFast Phx AST Profile C# VB C++ C++ Lex/Yacc Delphi Cobol Eiffel Tiger

Phoenix Architecture Core set of extensible classes to represent IR, Symbols, Types, Graphs, Trees, Regions Layered set of analysis and transformations components Data Flow Analysis, Loops, Aliasing, Dead Code, Redundant Code, Inlining Common input/output library for binary formats PE, LIB, OBJ, CIL, MSIL, PDB

We’ll demo a Phoenix-based c2 Demo 1: Code Generation Microsoft C++ compiler Input: program text Output: COFF object file We’ll demo a Phoenix-based c2 Driver (CL) C++ Source Frontend (C1) Backend (C2) Obj File

IR States Abstract Concrete AST HIR MIR LIR EIR Lowering Raising Phases transform IR, either within a state or from one state to another. For instance, Lower transforms MIR into LIR.

View inside Phoenix-Based C2 U R C E O B J E C T C I L AST HIR MIR LIR EIR CIL Reader Type Checker MIR Lower SSA Const SSA Dest Canon Addr Modes Lower Reg Alloc EH Lower Stack Alloc Frame Gen Switch Lower Block Layout Flow Opts Encode Lister C1 C2

Extending Phoenix All Phoenix clients can host plug-ins Plug-ins can Add new components Extend existing components Reconfigure clients Extensibility relies on Reflection Events & Delegates

Example: Uninitialized Local Detection Would like to warn the user that ‘x’ is not initialized before use To do this we need to perform a dataflow analysis within the compiler We’ll add a phase to C2 to do this, via a plug-in int foo() { int x; return x; }

Detecting an Uninitialized Use For each local variable v Examine all paths from the entry of the method to each use of v If on every path v is not initialized before the use: v must be used before it is defined If there is some path where v is not initialized before the use: v may be used before it is defined

Classic Solution Build control flow graph, solve data flow problem Unknown is the “state of v” at start of each block: Transfer function relates output of block to input: Meet combines outputs from predecessor blocks Undefined Defined Mixed If block contains v= Else output = input start start v = v = must = v may =v

Code sketch using dataflow bool changed = true; while (changed) { for each (Phx::Graphs::BasicBlock block in func) STATE ^ inState = inStates[block]; bool firstPred = true; for each(Phx::Graphs::BasicBlock predBlock in block->Predecessors) STATE ^ predState = outStates[predBlock]; inState = meet(inState, predState); } inStates[id] = inState; STATE ^ newOutState = gcnew STATE(inState); for each(Phx::IR::Instr ^ instr in block->Instrs) for each (Phx::IR::Opnd ^ opnd in instr->DstOpnds) Phx::Syms::LocalVarSym ^ localSym = opnd->Sym->AsLocalVarSym; newOutState[localSym] = dst(newOutState[localSym]); STATE ^ outState = outStates[id]; bool blockChanged = ! equals(newOutState, outState); if (blockChanged) changed = true; outStates[id] = newOutState; Update input state Compute output state Check for convergence

Demo: Unintialized Local Plug-In UninitializedLocal.cpp Test.cpp C++/CLI C1 UninitialzedLocal.dll Phx-C2 Test.obj To Run: cl -d2plugin: UninitializedLocal.dll -c Test.cpp

Demo 3: Phoenix PE Explorer Phoenix can also read and write PE files directly Implement your own compiler or linker Create post link tools for analysis, instrumentation or optimization Phx-Explorer is only ~800 LOC client code on top of Phoenix core library Or possibly the control flow graph plugin into visual studio…

Demo 4: Binary Rewriting mtrace injects tracing code into managed applications

Phoenix IR vs MSIL Phoenix IR makes everything explicit: Operands Control flow Exception handling Side effects Memory model Better format for analysis and transformation Identical model for .Net and native code Many analyses don’t need to make a distinction

Current Status RDKs released every 6 mos (May 06) with regular updates. Phoenix is now building Vista ~15 universities engaged via academic program Code quality, code size, features, compile times not yet on par with the retail product (but closing ground fast).

Recap Phoenix is a powerful and flexible framework for compilers & tools C2 backend PE file read/write JIT & PreJIT (not shown) Universal plugins on a common IR You can use the same components we use in your own work. Download available now Prerequisite: VS2005 (VC++ Express will work, mostly) Evaluation license prohibits redist or commercial use

More Info http://research.microsoft.com/phoenix

Summary Phoenix is Microsoft’s next-generation tools and code generation framework It’s written entirely in C++/CLI It’s available for you to experiment with now…

Questions? http://research.microsoft.com/phoenix andya@microsoft.com