GCC—An Architectural Overview, Current Status, and Future Directions

Total Page:16

File Type:pdf, Size:1020Kb

GCC—An Architectural Overview, Current Status, and Future Directions GCC—An Architectural Overview, Current Status, and Future Directions Diego Novillo Red Hat Canada [email protected] Abstract GCC one of the most popular compilers in use today. It serves as the system compiler for every Linux distribution and it is also fairly The GNU Compiler Collection (GCC) is one popular in academic circles, where it is used of the most popular compilers available and it for compiler research. Despite this popular- is the de facto system compiler for Linux sys- ity, GCC has traditionally proven difficult to tems. Despite its popularity, the internal work- maintain and enhance, to the extreme that some ings of GCC are relatively unknown outside of features were almost impossible to implement. the immediate developer community. And as a result GCC was starting to lag behind This paper provides a high-level architectural the competition. overview of GCC, its internal modules, and Part of the problem is the size of its code base. how it manages to support a wide variety of While GCC is not huge by industry standards, hardware architectures and languages. Special it still is a fairly large project, with a core emphasis is placed on high-level descriptions of about 1.3 MLOC. Including the runtime li- of the different modules to provide a roadmap braries needed for all the language support, to GCC. GCC comes to about 2.2 MLOC.1 Finally, the paper also describes recent techno- logical improvements that have been added to Size is not the only hurdle presented by GCC. GCC and discusses some of the major features Compilers are inherently complex and very de- that the developer community is thinking for manding in terms of the theoretical knowl- future versions of the compiler. edge required, particularly in the area of opti- mization and analysis. Additionally, compilers are dull, dreary and rarely provide immediate gratification, as interesting features often take 1 Introduction weeks or months to implement. Over the last few releases, GCC’s internal in- The GNU Compiler Collection (GCC) has frastructure has been overhauled to address evolved from a relatively modest C compiler these problems. This has facilitated the im- to a multi-language compiler that can generate code for more than 30 architectures. This di- 1Data generated using David A. Wheeler’s ’SLOC- versity of languages and architectures has made Count’. 186 • GCC—An Architectural Overview, Current Status, and Future Directions plementation of a new SSA based global opti- lows all directory names are assumed to be rel- mizer, sophisticated data dependency analyses, ative to the root directory where GCC sources a multi-platform vectoriser, a memory bounds live. checker (mudflap) and several other new fea- tures. 2.1 Core This paper describes the major components in GCC and their internal organization. Note that The gcc directory contains the C front end, this is not intended to be a replacement for middle end, target-independent back end com- GCC’s internal documentation. Many modules ponents, and a host of other modules needed are overlooked or described only briefly. The by various parts of the compiler. This includes intent of this document is to serve as introduc- diagnostic and error machinery, the driver pro- tory material for anyone interested in extending gram, option handling, and data structures such or maintaining GCC. as bitmaps, sets, etc. The other front ends are contained in their own subdirectories: gcc/ada, gcc/cp (C++), 2 Overview of GCC gcc/fortran (Fortran 95), gcc/java, gcc/objc (Objective-C), gcc/objcp (Ob- GCC is essentially a big pipeline that converts jective C++), and gcc/treelang, which is a one program representation into another. There small toy language used as an example of how are three main components: front end (FE), to implement front ends. middle end (ME)2 and back end (BE). Source gcc/config code enters the front end and flows through the Directories inside contain all pipeline, being converted at each stage into suc- the target-dependent back end components. cessively lower-level representation forms until This includes the machine description (MD) final code generation in the form of assembly files that describe code generation patterns code that is then fed into the assembler. and support functions used by the target- independent back end functions. Figure 1 shows a bird’s eye view of the com- piler. Notice that the different phases are se- 2.2 Runtime quenced by the Call Graph and Pass managers. The call graph manager builds a call graph for the compilation unit and decides in which or- Most languages and some GCC features require der to process each function. It also drives a runtime component, which can be found at the inter-procedural optimizations (IPO) such the top of the directory tree: as inlining. The pass manager is responsible for sequencing the individual transformations The Java runtime is in boehm-gc (garbage and handling pre and post cleanup actions as collection), libffi (foreign function in- needed by each pass. terface), libjava and zlib. The source code is organized in three major The Ada, C++, Fortran 95 and groups: core, runtime and support. In what fol- Objective-C runtime are in libada, 2Consistency in naming conventions led to this unfor- libstdc++-v3, libgfortran and tunate term. libobjc respectively. 2006 Linux Symposium, Volume Two • 187 C C++ Java Fortran parser parser parser parser Pass Manager Front End (FE) GENERIC Inlining Constant Propagation (IPCP) Static variable analysis Points-to alias analysis Middle End (ME) GIMPLE Flow sensitive and flow insensitive alias analysis Constant Propagation (CCP) Interprocedural Full Redundancy Elimination (FRE) Optimizer Dead Code Elimination (DCE) Forward Propagation Jump Threading Copy Propagation (COPY-PROP) Call Graph SSA Value Range Propagation (VRP) Manager Optimizer Scalar Replacement of Aggregates (SRA) Dead Store Elimination (DSE) Tail Call discovery Partial Redundancy Elimination (PRE) Loop Optimizations Loop Invariant Motion (LIM) Back End (BE) RTL Loop Unswitching Loop Interchange Induction Variable Optimizations If conversion Vectorization RTL Loop Prefetching Optimizer Loop Unrolling Empty Loop Elimination Assembly Sibling/tail call optimization Life and Data Flow Analysis Common Subexpression Elimination (CSE) Branch prediction Instruction Combination Mode Switching Instruction Scheduling Register Allocation Register Renaming Peephole Optimizations Branch Shortening Machine Specific Reorganizations Figure 1: An Overview of GCC 188 • GCC—An Architectural Overview, Current Status, and Future Directions The preprocessor is implemented as a separate 2 is the stabilization phase, only minor fea- library in libcpp. tures are allowed and bug fixes that maintain- ers consider safe to include. Stage 3 marks A decimal arithmetic library is included in the preparation for release. During this phase libdecnumber. only bug and documentation fixes are allowed. In particular, these bug fixes are usually re- The OpenMP [14] runtime is in libgomp. quired to have a corresponding entry in GCC’s Mudflap [6], the pointer and memory check bug tracking database (http://gcc.gnu. facility, has its runtime component in org/bugzilla). libmudflap. At the end of stage 3, the release manager will The library functions for SSP (Stack Smash cut a release branch. Stabilization work con- Protection) are in libssp. tinues on the release branch and a release crite- ria is agreed by consensus between the release manager and the maintainers. Release block- 2.3 Support ing bugs are identified in the bugzilla database and the release is done once all the critical bugs have been fixed.3 Once the release branch is Various utility functions and generic data struc- created, Stage 1 for the next release begins. tures, such as bitmaps, sets, queues, etc. are im- plemented in libiberty. The configuration and build machinery live in build and vari- Using this system, GCC is averaging about a ous scripts useful for developers are stored in couple of releases a year. Once version X.Y is contrib. released, subsequent releases in the X.Y series continues. In this case, another release manager takes over the X.Y series, which accepts no new 2.4 Development Model features, just bug fixes. Major development that spans multiple releases All the major decisions in GCC are taken by is done in branches. Anyone with write access the GCC Steering Committee. This usually to the GCC repository may create a develop- includes determining maintainership rights for ment branch and develop the new feature on contributors, interfacing with the FSF, approv- the branch. When that feature is ready, they ing the inclusion of major features and other can propose including it at the next Stage 1. administrative and political decisions regard- Vendors usually create their own branches from ing the project. All these decisions are guided FSF release branches. by GCC’s mission statement (http://gcc. gnu.org/gccmission.html). All contributors must sign an FSF copyright re- lease to be able to contribute to GCC. If the GCC goes through three distinct development work is done as part of their employment, their stages, which are coordinated by GCC’s re- employer must also sign a copyright release lease manager and its maintainers. Each stage form to the FSF. usually lasts between 3 and 5 months. Dur- ing Stage 1, big and disruptive changes are 3It may also happen that some of these bugs are sim- allowed. This is where all the major fea- ply moved over to the next release, if they are not deemed tures are incorporated into the compiler. Stage to be as critical as initially thought. 2006 Linux Symposium, Volume Two • 189 3 GENERIC Representation f(int a, int b, int c) { if (g (a + b, c)) Every language front end is responsible for all c = b++ / a the syntactic and semantic processing for the return c corresponding input language.
Recommended publications
  • CSE 582 – Compilers
    CSE P 501 – Compilers Optimizing Transformations Hal Perkins Autumn 2011 11/8/2011 © 2002-11 Hal Perkins & UW CSE S-1 Agenda A sampler of typical optimizing transformations Mostly a teaser for later, particularly once we’ve looked at analyzing loops 11/8/2011 © 2002-11 Hal Perkins & UW CSE S-2 Role of Transformations Data-flow analysis discovers opportunities for code improvement Compiler must rewrite the code (IR) to realize these improvements A transformation may reveal additional opportunities for further analysis & transformation May also block opportunities by obscuring information 11/8/2011 © 2002-11 Hal Perkins & UW CSE S-3 Organizing Transformations in a Compiler Typically middle end consists of many individual transformations that filter the IR and produce rewritten IR No formal theory for order to apply them Some rules of thumb and best practices Some transformations can be profitably applied repeatedly, particularly if others transformations expose more opportunities 11/8/2011 © 2002-11 Hal Perkins & UW CSE S-4 A Taxonomy Machine Independent Transformations Realized profitability may actually depend on machine architecture, but are typically implemented without considering this Machine Dependent Transformations Most of the machine dependent code is in instruction selection & scheduling and register allocation Some machine dependent code belongs in the optimizer 11/8/2011 © 2002-11 Hal Perkins & UW CSE S-5 Machine Independent Transformations Dead code elimination Code motion Specialization Strength reduction
    [Show full text]
  • Generalized Jump Threading in Libfirm
    Institut für Programmstrukturen und Datenorganisation (IPD) Lehrstuhl Prof. Dr.-Ing. Snelting Generalized Jump Threading in libFIRM Masterarbeit von Joachim Priesner an der Fakultät für Informatik Erstgutachter: Prof. Dr.-Ing. Gregor Snelting Zweitgutachter: Prof. Dr.-Ing. Jörg Henkel Betreuender Mitarbeiter: Dipl.-Inform. Andreas Zwinkau Bearbeitungszeit: 5. Oktober 2016 – 23. Januar 2017 KIT – Die Forschungsuniversität in der Helmholtz-Gemeinschaft www.kit.edu Zusammenfassung/Abstract Jump Threading (dt. „Sprünge fädeln“) ist eine Compileroptimierung, die statisch vorhersagbare bedingte Sprünge in unbedingte Sprünge umwandelt. Bei der Ausfüh- rung kann ein Prozessor bedingte Sprünge zunächst nur heuristisch mit Hilfe der Sprungvorhersage auswerten. Sie stellen daher generell ein Performancehindernis dar. Die Umwandlung ist insbesondere auch dann möglich, wenn das Sprungziel nur auf einer Teilmenge der zu dem Sprung führenden Ausführungspfade statisch be- stimmbar ist. In diesem Fall, der den überwiegenden Teil der durch Jump Threading optimierten Sprünge betrifft, muss die Optimierung Grundblöcke duplizieren, um jene Ausführungspfade zu isolieren. Verschiedene aktuelle Compiler enthalten sehr unterschiedliche Implementierungen von Jump Threading. In dieser Masterarbeit wird zunächst ein theoretischer Rahmen für Jump Threading vorgestellt. Sodann wird eine allgemeine Fassung eines Jump- Threading-Algorithmus entwickelt, implementiert und in diverser Hinsicht untersucht, insbesondere auf Wechselwirkungen mit anderen Optimierungen wie If
    [Show full text]
  • ICS803 Elective – III Multicore Architecture Teacher Name: Ms
    ICS803 Elective – III Multicore Architecture Teacher Name: Ms. Raksha Pandey Course Structure L T P 3 1 0 4 Prerequisite: Course Content: Unit-I: Multi-core Architectures Introduction to multi-core architectures, issues involved into writing code for multi-core architectures, Virtual Memory, VM addressing, VA to PA translation, Page fault, TLB- Parallel computers, Instruction level parallelism (ILP) vs. thread level parallelism (TLP), Performance issues, OpenMP and other message passing libraries, threads, mutex etc. Unit-II: Multi-threaded Architectures Brief introduction to cache hierarchy - Caches: Addressing a Cache, Cache Hierarchy, States of Cache line, Inclusion policy, TLB access, Memory Op latency, MLP, Memory Wall, communication latency, Shared memory multiprocessors, General architectures and the problem of cache coherence, Synchronization primitives: Atomic primitives; locks: TTS, ticket, array; barriers: central and tree; performance implications in shared memory programs; Chip multiprocessors: Why CMP (Moore's law, wire delay); shared L2 vs. tiled CMP; core complexity; power/performance; Snoopy coherence: invalidate vs. update, MSI, MESI, MOESI, MOSI; performance trade-offs; pipelined snoopy bus design; Memory consistency models: SC, PC, TSO, PSO, WO/WC, RC; Chip multiprocessor case studies: Intel Montecito and dual-core, Pentium4, IBM Power4, Sun Niagara Unit-III: Compiler Optimization Issues Code optimizations: Copy Propagation, dead Code elimination , Loop Optimizations-Loop Unrolling, Induction variable Simplification, Loop Jamming, Loop Unswitching, Techniques to improve detection of parallelism: Scalar Processors, Special locality, Temporal locality, Vector machine, Strip mining, Shared memory model, SIMD architecture, Dopar loop, Dosingle loop. Unit-IV: Control Flow analysis Control flow analysis, Flow graph, Loops in Flow graphs, Loop Detection, Approaches to Control Flow Analysis, Reducible Flow Graphs, Node Splitting.
    [Show full text]
  • Fast-Path Loop Unrolling of Non-Counted Loops to Enable Subsequent Compiler Optimizations∗
    Fast-Path Loop Unrolling of Non-Counted Loops to Enable Subsequent Compiler Optimizations∗ David Leopoldseder Roland Schatz Lukas Stadler Johannes Kepler University Linz Oracle Labs Oracle Labs Austria Linz, Austria Linz, Austria [email protected] [email protected] [email protected] Manuel Rigger Thomas Würthinger Hanspeter Mössenböck Johannes Kepler University Linz Oracle Labs Johannes Kepler University Linz Austria Zurich, Switzerland Austria [email protected] [email protected] [email protected] ABSTRACT Non-Counted Loops to Enable Subsequent Compiler Optimizations. In 15th Java programs can contain non-counted loops, that is, loops for International Conference on Managed Languages & Runtimes (ManLang’18), September 12–14, 2018, Linz, Austria. ACM, New York, NY, USA, 13 pages. which the iteration count can neither be determined at compile https://doi.org/10.1145/3237009.3237013 time nor at run time. State-of-the-art compilers do not aggressively optimize them, since unrolling non-counted loops often involves 1 INTRODUCTION duplicating also a loop’s exit condition, which thus only improves run-time performance if subsequent compiler optimizations can Generating fast machine code for loops depends on a selective appli- optimize the unrolled code. cation of different loop optimizations on the main optimizable parts This paper presents an unrolling approach for non-counted loops of a loop: the loop’s exit condition(s), the back edges and the loop that uses simulation at run time to determine whether unrolling body. All these parts must be optimized to generate optimal code such loops enables subsequent compiler optimizations. Simulat- for a loop.
    [Show full text]
  • Compiler Optimization for Configurable Accelerators Betul Buyukkurt Zhi Guo Walid A
    Compiler Optimization for Configurable Accelerators Betul Buyukkurt Zhi Guo Walid A. Najjar University of California Riverside University of California Riverside University of California Riverside Computer Science Department Electrical Engineering Department Computer Science Department Riverside, CA 92521 Riverside, CA 92521 Riverside, CA 92521 [email protected] [email protected] [email protected] ABSTRACT such as constant propagation, constant folding, dead code ROCCC (Riverside Optimizing Configurable Computing eliminations that enables other optimizations. Then, loop Compiler) is an optimizing C to HDL compiler targeting level optimizations such as loop unrolling, loop invariant FPGA and CSOC (Configurable System On a Chip) code motion, loop fusion and other such transforms are architectures. ROCCC system is built on the SUIF- applied. MACHSUIF compiler infrastructure. Our system first This paper is organized as follows. Next section discusses identifies frequently executed kernel loops inside programs on the related work. Section 3 gives an in depth description and then compiles them to VHDL after optimizing the of the ROCCC system. SUIF2 level optimizations are kernels to make best use of FPGA resources. This paper described in Section 4 followed by the compilation done at presents an overview of the ROCCC project as well as the MACHSUIF level in Section 5. Section 6 mentions our optimizations performed inside the ROCCC compiler. early results. Finally Section 7 concludes the paper. 1. INTRODUCTION 2. RELATED WORK FPGAs (Field Programmable Gate Array) can boost There are several projects and publications on translating C software performance due to the large amount of or other high level languages to different HDLs. Streams- parallelism they offer.
    [Show full text]
  • Functional Array Programming in Sac
    Functional Array Programming in SaC Sven-Bodo Scholz Dept of Computer Science, University of Hertfordshire, United Kingdom [email protected] Abstract. These notes present an introduction into array-based pro- gramming from a functional, i.e., side-effect-free perspective. The first part focuses on promoting arrays as predominant, stateless data structure. This leads to a programming style that favors compo- sitions of generic array operations that manipulate entire arrays over specifications that are made in an element-wise fashion. An algebraicly consistent set of such operations is defined and several examples are given demonstrating the expressiveness of the proposed set of operations. The second part shows how such a set of array operations can be defined within the first-order functional array language SaC.Itdoes not only discuss the language design issues involved but it also tackles implementation issues that are crucial for achieving acceptable runtimes from such genericly specified array operations. 1 Introduction Traditionally, binary lists and algebraic data types are the predominant data structures in functional programming languages. They fit nicely into the frame- work of recursive program specifications, lazy evaluation and demand driven garbage collection. Support for arrays in most languages is confined to a very resricted set of basic functionality similar to that found in imperative languages. Even if some languages do support more advanced specificational means such as array comprehensions, these usualy do not provide the same genericity as can be found in array programming languages such as Apl,J,orNial. Besides these specificational issues, typically, there is also a performance issue.
    [Show full text]
  • Loop Transformations and Parallelization
    Loop transformations and parallelization Claude Tadonki LAL/CNRS/IN2P3 University of Paris-Sud [email protected] December 2010 Claude Tadonki Loop transformations and parallelization C. Tadonki – Loop transformations Introduction Most of the time, the most time consuming part of a program is on loops. Thus, loops optimization is critical in high performance computing. Depending on the target architecture, the goal of loops transformations are: improve data reuse and data locality efficient use of memory hierarchy reducing overheads associated with executing loops instructions pipeline maximize parallelism Loop transformations can be performed at different levels by the programmer, the compiler, or specialized tools. At high level, some well known transformations are commonly considered: loop interchange loop (node) splitting loop unswitching loop reversal loop fusion loop inversion loop skewing loop fission loop vectorization loop blocking loop unrolling loop parallelization Claude Tadonki Loop transformations and parallelization C. Tadonki – Loop transformations Dependence analysis Extract and analyze the dependencies of a computation from its polyhedral model is a fundamental step toward loop optimization or scheduling. Definition For a given variable V and given indexes I1, I2, if the computation of X(I1) requires the value of X(I2), then I1 ¡ I2 is called a dependence vector for variable V . Drawing all the dependence vectors within the computation polytope yields the so-called dependencies diagram. Example The dependence vectors are (1; 0); (0; 1); (¡1; 1). Claude Tadonki Loop transformations and parallelization C. Tadonki – Loop transformations Scheduling Definition The computation on the entire domain of a given loop can be performed following any valid schedule.A timing function tV for variable V yields a valid schedule if and only if t(x) > t(x ¡ d); 8d 2 DV ; (1) where DV is the set of all dependence vectors for variable V .
    [Show full text]
  • Improving the Compilation Process Using Program Annotations
    POLITECNICO DI MILANO Corso di Laurea Magistrale in Ingegneria Informatica Dipartimento di Elettronica, Informazione e Bioingegneria Improving the Compilation process using Program Annotations Relatore: Prof. Giovanni Agosta Correlatore: Prof. Lenore Zuck Tesi di Laurea di: Niko Zarzani, matricola 783452 Anno Accademico 2012-2013 Alla mia famiglia Alla mia ragazza Ai miei amici Ringraziamenti Ringrazio in primis i miei relatori, Prof. Giovanni Agosta e Prof. Lenore Zuck, per la loro disponibilità, i loro preziosi consigli e il loro sostegno. Grazie per avermi seguito sia nel corso della tesi che della mia carriera universitaria. Ringrazio poi tutti coloro con cui ho avuto modo di confrontarmi durante la mia ricerca, Dr. Venkat N. Venkatakrishnan, Dr. Rigel Gjomemo, Dr. Phu H. H. Phung e Giacomo Tagliabure, che mi sono stati accanto sin dall’inizio del mio percorso di tesi. Voglio ringraziare con tutto il cuore la mia famiglia per il prezioso sup- porto in questi anni di studi e Camilla per tutto l’amore che mi ha dato anche nei momenti più critici di questo percorso. Non avrei potuto su- perare questa avventura senza voi al mio fianco. Ringrazio le mie amiche e i miei amici più cari Ilaria, Carolina, Elisa, Riccardo e Marco per la nostra speciale amicizia a distanza e tutte le risate fatte assieme. Infine tutti i miei conquilini, dai più ai meno nerd, per i bei momenti pas- sati assieme. Ricorderò per sempre questi ultimi anni come un’esperienza stupenda che avete reso memorabile. Mi mancherete tutti. Contents 1 Introduction 1 2 Background 3 2.1 Annotated Code . .3 2.2 Sources of annotated code .
    [Show full text]
  • Compiler-Based Code-Improvement Techniques
    Compiler-Based Code-Improvement Techniques KEITH D. COOPER, KATHRYN S. MCKINLEY, and LINDA TORCZON Since the earliest days of compilation, code quality has been recognized as an important problem [18]. A rich literature has developed around the issue of improving code quality. This paper surveys one part of that literature: code transformations intended to improve the running time of programs on uniprocessor machines. This paper emphasizes transformations intended to improve code quality rather than analysis methods. We describe analytical techniques and specific data-flow problems to the extent that they are necessary to understand the transformations. Other papers provide excellent summaries of the various sub-fields of program analysis. The paper is structured around a simple taxonomy that classifies transformations based on how they change the code. The taxonomy is populated with example transformations drawn from the literature. Each transformation is described at a depth that facilitates broad understanding; detailed references are provided for deeper study of individual transformations. The taxonomy provides the reader with a framework for thinking about code-improving transformations. It also serves as an organizing principle for the paper. Copyright 1998, all rights reserved. You may copy this article for your personal use in Comp 512. Further reproduction or distribution requires written permission from the authors. 1INTRODUCTION This paper presents an overview of compiler-based methods for improving the run-time behavior of programs — often mislabeled code optimization. These techniques have a long history in the literature. For example, Backus makes it quite clear that code quality was a major concern to the implementors of the first Fortran compilers [18].
    [Show full text]
  • Survey of Compiler Technology at the IBM Toronto Laboratory
    An (incomplete) Survey of Compiler Technology at the IBM Toronto Laboratory Bob Blainey March 26, 2002 Target systems Sovereign (Sun JDK-based) Just-in-Time (JIT) Compiler zSeries (S/390) OS/390, Linux Resettable, shareable pSeries (PowerPC) AIX 32-bit and 64-bit Linux xSeries (x86 or IA-32) Windows, OS/2, Linux, 4690 (POS) IA-64 (Itanium, McKinley) Windows, Linux C and C++ Compilers zSeries OS/390 pSeries AIX Fortran Compiler pSeries AIX Key Optimizing Compiler Components TOBEY (Toronto Optimizing Back End with Yorktown) Highly optimizing code generator for S/390 and PowerPC targets TPO (Toronto Portable Optimizer) Mostly machine-independent optimizer for Wcode intermediate language Interprocedural analysis, loop transformations, parallelization Sun JDK-based JIT (Sovereign) Best of breed JIT compiler for client and server applications Based very loosely on Sun JDK Inside a Batch Compilation C source C++ source Fortran source Other source C++ Front Fortran C Front End Other Front End Front End Ends Wcode Wcode Wcode++ Wcode Wcode TPO Wcode Scalarizer Wcode TOBEY Wcode Back End Object Code TOBEY Optimizing Back End Project started in 1983 targetting S/370 Later retargetted to ROMP (PC-RT), Power, Power2, PowerPC, SPARC, and ESAME/390 (64 bit) Experimental retargets to i386 and PA-RISC Shipped in over 40 compiler products on 3 different platforms with 8 different source languages Primary vehicle for compiler optimization since the creation of the RS/6000 (pSeries) Implemented in a combination of PL.8 ("80% of PL/I") and C++ on an AIX reference
    [Show full text]
  • Control Flow Graphs
    CONTROL FLOW GRAPHS PROGRAM ANALYSIS AND OPTIMIZATION – DCC888 Fernando Magno Quintão Pereira [email protected] The material in these slides have been taken from the "Dragon Book", Secs 8.5 – 8.7, by Aho et al. Intermediate Program Representations • Optimizing compilers and human beings do not see the program in the same way. – We are more interested in source code. – But, source code is too different from machine code. – Besides, from an engineering point of view, it is better to have a common way to represent programs in different languages, and target different architectures. Fortran PowerPC COBOL x86 Front Back Optimizer Lisp End End ARM … … Basic Blocks and Flow Graphs • Usually compilers represent programs as control flow graphs (CFG). • A control flow graph is a directed graph. – Nodes are basic blocks. – There is an edge from basic block B1 to basic block B2 if program execution can flow from B1 to B2. • Before defining basic void identity(int** a, int N) { int i, j; block, we will illustrate for (i = 0; i < N; i++) { this notion by showing the for (j = 0; j < N; j++) { a[i][j] = 0; CFG of the function on the } right. } for (i = 0; i < N; i++) { What does a[i][i] = 1; this program } do? } The Low Level Virtual Machine • We will be working with a compilation framework called The Low Level Virtual Machine, or LLVM, for short. • LLVM is today the most used compiler in research. • Additionally, this compiler is used in many important companies: Apple, Cray, Google, etc. The front-end Machine independent Machine dependent that parses C optimizations, such as optimizations, such into bytecodes constant propagation as register allocation ../0 %"&'( *+, ""% !"#$% !"#$)% !"#$)% !"#$- Using LLVM to visualize a CFG • We can use the opt tool, the LLVM machine independent optimizer, to visualize the control flow graph of a given function $> clang -c -emit-llvm identity.c -o identity.bc $> opt –view-cfg identity.bc • We will be able to see the CFG of our target program, as long as we have the tool DOT installed in our system.
    [Show full text]
  • GCC Internals
    GCC Internals Diego Novillo [email protected] Red Hat Canada CGO 2007 San Jose, California March 2007 Outline 1. Overview 2. Source code organization 3. Internal architecture 4. Passes NOTE: Internal information valid for GCC mainline as of 2007-03-02 11 March 2007 GCC Internals - 2 1. Overview ➢ Major features ➢ Brief history ➢ Development model 11 March 2007 GCC Internals - 3 Major Features Availability – Free software (GPL) – Open and distributed development process – System compiler for popular UNIX variants – Large number of platforms (deeply embedded to big iron) – Supports all major languages: C, C++, Java, Fortran 95, Ada, Objective-C, Objective-C++, etc 11 March 2007 GCC Internals - 4 Major Features Code quality – Bootstraps on native platforms – Warning-free – Extensive regression testsuite – Widely deployed in industrial and research projects – Merit-based maintainership appointed by steering committee – Peer review by maintainers – Strict coding standards and patch reversion policy 11 March 2007 GCC Internals - 5 Major Features Analysis/Optimization – SSA-based high-level global optimizer – Constraint-based points-to alias analysis – Data dependency analysis based on chains of recurrences – Feedback directed optimization – Interprocedural optimization – Automatic pointer checking instrumentation – Automatic loop vectorization – OpenMP support 11 March 2007 GCC Internals - 6 1. Overview ➢ Major features ➢ Brief history ➢ Development model 11 March 2007 GCC Internals - 7 Brief History GCC 1 (1987) – Inspired on Pastel compiler
    [Show full text]