Low-Overhead Debugging Support for an LLVM IR Interpreter

Total Page:16

File Type:pdf, Size:1020Kb

Low-Overhead Debugging Support for an LLVM IR Interpreter Submitted by Jacob Kreindl, BSc. Submitted at Institut f¨ur Systemsoftware Supervisor o.Univ.-Prof. Dipl.-Ing. Dr.Dr.h.c. Hanspeter Source-Level M¨ossenb¨ock Co-Supervisors Debugging Support Dipl.-Ing. Dr. Matthias Grimmer Dipl.-Ing. Manuel in an LLVM-IR Rigger Interpreter April 2018 Master Thesis to obtain the academic degree of Diplom-Ingenieur in the Master’s Program Computer Science JOHANNES KEPLER UNIVERSITY LINZ Altenbergerstraße 69 4040 Linz, Osterreich¨ www.jku.at DVR 0093696 2 Abstract Sulong executes programs that are compiled to LLVM IR, the language-independent intermedi- ate representation of source code used by the LLVM compiler infrastructure, on the Java Virtual Machine (JVM). The interpreter is based on the Truffle language implementation framework and is part of the GraalVM project. Truffle provides a versatile debugger backend which en- ables source-level inspection of programs it executes even across language boundaries. This thesis describes how Sulong leverages debug information available in LLVM IR bitcode files to support this feature. First, the thesis describes how Sulong relates programs it executes to locations in their original source code. It further presents the necessary extensions to the interpreter’s execution data structures that enable the debugger backend to facilitate source-level single-stepping and set breakpoints. Next, the thesis defines multiple layers of abstraction from LLVM IR as well as Sulong’s internal data model that provide a source-level view of an interpreted program’s runtime state which includes language-specific display of types, scopes and values. It also introduces specialized data structures to efficiently represent runtime debug information. This thesis demonstrates the capabilities of the presented approach by inspecting a native Ruby extension implemented in C++ at runtime. A performance evaluation further shows that runtime overhead in terms of execution time introduced by instrumentation and symbol inspection is negligible in many cases. 3 Kurzfassung Sulong führt Programme auf der Java Virtual Machine (JVM) aus, die zu LLVM IR kompiliert wurden, der sprachunabhängigen Repräsentation von Quellcode, die die LLVM Compiler Infras- truktur verwendet. Der Interpreter basiert auf dem Truffle Framework zur Implementierung von Programmiersprachen und ist Teil des GraalVM Projekts. Truffle stellt ein vielseitiges Debugger Backend zur Verfügung, welches das Inspizieren von Programmen, die es ausführt, ermöglicht, auch über mehrere Programmiersprachen hinweg. Diese Masterarbeit beschreibt, wie Sulong Debug Information in LLVM IR Bitcode Dateien verwendet, um dieses Feature zu unterstützen. Die Masterarbeit beschreibt zunächst, wie Sulong die Programme, die es ausführt, auf den ur- sprünglichen Quellcode zurückführt. Des weiteren präsentiert sie die notwendigen Erweiterun- gen zu den Datenstrukturen des Interpreters, die es dem Debugger Backend ermöglichen, Gast- programme auf Level derer ursprünglichen Programmiersprache Schritt-für-Schritt auszuführen und Haltepunkte in ihnen zu setzen. Des weiteren definiert die Masterarbeit mehrere Abstraktionsschichten von LLVM IR und Su- longs internem Datenmodell, die eine Sicht auf den Laufzeitzustand eines Gastprogramms ermöglichen, die dessen ursprünglicher Programmiersprache entspricht, was sprachspezifische Darstellung von Typen, Scopes und Werten beinhaltet. Sie beschreibt auch spezialisierte Daten- strukturen zur effizienten Repräsentation von Debug Information zur Laufzeit. Diese Masterarbeit demonstriert die Fähigkeiten des präsentierten Ansatzes durch das In- spizieren einer Ruby Erweiterung zur Laufzeit, die in C++ implementiert wurde. Eine Performance- Evaluierung zeigt des weiteren, dass der Laufzeit Overhead in Form von Ausführungszeit, den Instrumentierung und Symbolinspektion erzeugen, in vielen Fällen vernachlässigbar ist. Contents 4 Contents 1 Introduction7 1.1 Motivation . .7 1.2 Goals and Scope . .8 1.3 Thesis Structure . .9 2 System Overview 10 2.1 The LLVM Compiler Infrastructure . 10 2.2 GraalVM . 12 2.2.1 Truffle . 12 2.2.2 Sulong . 16 3 LLVM IR 17 3.1 General Structure . 17 3.1.1 Scopes . 18 3.1.2 Data flow . 19 3.1.3 Control flow . 20 3.1.4 Type system . 20 3.2 Representations . 21 3.3 Binary Encoding . 22 3.3.1 Symbol Table . 23 3.3.2 High-Level File Structure . 24 4 Debug Information 26 4.1 LLVM IR Metadata . 26 4.1.1 Structure . 27 4.1.2 Encoding . 28 4.2 LLVM IR Debug Information . 31 4.2.1 Locations . 32 Contents 5 4.2.2 Symbols . 32 4.2.3 Types . 33 4.2.4 Scopes . 35 4.3 Value Mapping . 37 4.3.1 Locals . 37 4.3.2 Globals . 38 5 Stepping & Breakpoints 40 5.1 Location Information . 40 5.1.1 Representation in Truffle . 41 5.1.2 Representation in Sulong . 42 5.2 Truffle Instrumentation . 44 5.2.1 Node Implementation . 45 5.2.2 Wrapper Implementation . 47 5.3 Dynamically Halting Execution in an Instrumented AST . 49 6 Source-Level Symbol Inspection 52 6.1 Symbol Information . 52 6.2 Symbol Inspection in Truffle . 55 6.3 Symbol Inspection in Sulong . 57 6.3.1 Value Layer . 57 6.3.2 Representation Layer . 60 6.3.3 Value Tracking . 62 7 Case Study 64 7.1 Program Description . 65 7.2 Analysis . 69 7.2.1 Stepping . 69 7.2.2 Symbol Inspection . 73 8 Evaluation 82 9 Future Work 86 10 Related Work 88 11 Conclusion 90 Contents 6 Bibliography 95 Introduction 7 Chapter 1 Introduction This chapter states the motivation for implementing support for source-level debug- ging in an LLVM IR interpreter. It also defines the scope of this thesis and provides an outline of its structure. 1.1 Motivation Real world software systems tend to be highly complex collections of source code frequently written in multiple programming languages. They are also often implemented and maintained by many different people. Intricate semantic nuances of many programming languages and necessarily subjective interpretation of even well-defined requirements already make it hard for developers to specify large programs entirely correctly. Different execution environments as well as optimizing compilers and interpreters add another source for possibly subtle bugs. This raises demand for versatile debuggers that help developers to detect errors at runtime under realistic conditions. However, most traditional approaches fail to support source-level inspection across language boundaries. As a result, developers often need to use multiple frontends to debug native extensions for programs in dynamic languages such as Ruby. Sulong is an interpreter for LLVM IR, a common representation of code in various low-level programming languages, including C, C++ and Fortran. It is based on the Truffle framework for implementing high-performance, interoperable Abstract Syntax Tree (AST) interpreters. Sulong Introduction 8 is also part of the GraalVM project where its main use-case is the execution of native extensions for various other Truffle-based implementations of dynamic programming languages. Truffle contains a framework for source-level program instrumentation and debugging. It re- quires individual language implementations to provide additional information in the AST and to define a language-specific representation of their runtime state. However, supporting it is optional. The goal of this thesis is to implement the necessary features in Sulong. Truffle generally supports source-level debugging across language boundaries in the same frontend. By implementing the corresponding API in Sulong we enable the important use-case of debugging native extensions for dynamic languages. 1.2 Goals and Scope Enabling support for source-level debugging in Sulong requires applying debug information in LLVM IR to relate nodes in the Truffle AST to locations in the source code, reconstruct the original program state from the interpreter’s execution of compiled code and providing a language-specific representation of it to Truffle’s debugger backend. The concrete scope of this thesis consists of the following goals. • Analyzing debug information in LLVM IR: This entails evaluating the information it contains as well as its encoding. • Relating Truffle AST and source code: This includes marking AST nodes that correspond to statements or other programming constructs and relating them to their respective locations in the source code and retaining the source-level scope hierarchy. • Supporting Truffle instrumentation: Extend Sulong’s implementation of AST nodes as required by Truffle’s framework for source-level program instrumentation. The debug- ging framework requires this to enable single-stepping and breakpoints. • Source-level symbol inspection: This requires abstracting the interpreter’s runtime state to provide a language-specific representation of source-level scope entries and their values in a format suitable for the debugging framework. Introduction 9 1.3 Thesis Structure This thesis starts with a general overview of the technologies it uses in Chapter2. Following this, Chapter3 introduces the basic concepts of LLVM IR and its different formats. Chapter4 continues with a more in-depth analysis of the content and encoding of debug information in LLVM IR files. Next, Chapter5 describes how Truffle implements program instrumentation and what this requires of Sulong. After this, the thesis describes in detail how the interpreter provides a language-specific view of the runtime state of programs it executes in Chapter6. Chapter7 then exercises a case study to demonstrate the previously discussed features. Follow- ing this, Chapter8 provides a short evaluation of the impact enabling debugging support has on execution performance.
Recommended publications
  • Intermediate Representation and LLVM
    CS153: Compilers Lecture 6: Intermediate Representation and LLVM Stephen Chong https://www.seas.harvard.edu/courses/cs153 Contains content from lecture notes by Steve Zdancewic and Greg Morrisett Announcements •Homework 1 grades returned •Style •Testing •Homework 2: X86lite •Due Tuesday Sept 24 •Homework 3: LLVMlite •Will be released Tuesday Sept 24 Stephen Chong, Harvard University 2 Today •Continue Intermediate Representation •Intro to LLVM Stephen Chong, Harvard University 3 Low-Level Virtual Machine (LLVM) •Open-Source Compiler Infrastructure •see llvm.org for full documentation •Created by Chris Lattner (advised by Vikram Adve) at UIUC •LLVM: An infrastructure for Multi-stage Optimization, 2002 •LLVM: A Compilation Framework for Lifelong Program Analysis and Transformation, 2004 •2005: Adopted by Apple for XCode 3.1 •Front ends: •llvm-gcc (drop-in replacement for gcc) •Clang: C, objective C, C++ compiler supported by Apple •various languages: Swift, ADA, Scala, Haskell, … •Back ends: •x86 / Arm / PowerPC / etc. •Used in many academic/research projects Stephen Chong, Harvard University 4 LLVM Compiler Infrastructure [Lattner et al.] LLVM llc frontends Typed SSA backend like IR code gen 'clang' jit Optimizations/ Transformations Analysis Stephen Chong, Harvard University 5 Example LLVM Code factorial-pretty.ll define @factorial(%n) { •LLVM offers a textual %1 = alloca %acc = alloca store %n, %1 representation of its IR store 1, %acc •files ending in .ll br label %start start: %3 = load %1 factorial64.c %4 = icmp sgt %3, 0 br %4, label
    [Show full text]
  • Ryan Holland CSC415 Term Paper Final Draft Language: Swift (OSX)
    Ryan Holland CSC415 Term Paper Final Draft Language: Swift (OSX) Apple released their new programming language "Swift" on June 2nd of this year. Swift replaces current versions of objective-C used to program in the OSX and iOS environments. According to Apple, swift will make programming apps for these environments "more fun". Swift is also said to bring a significant boost in performance compared to the equivalent objective-C. Apple has not released an official document stating the reasoning behind the launch of Swift, but speculation is that it was a move to attract more developers to the iOS platform. Swift development began in 2010 by Chris Lattner, but would later be aided by many other programmers. Swift employs ideas from many languages into one, not only from objective-C. These languages include Rust, Haskell, Ruby, Python, C#, CLU mainly but many others are also included. Apple says that most of the language is built for Cocoa and Cocoa Touch. Apple claims that Swift is more friendly to new programmers, also claiming that the language is just as enjoyable to learn as scripting languages. It supports a feature known as playgrounds, that allow programmers to make modifications on the fly, and see results immediately without the need to build the entire application first. Apple controls most aspects of this language, and since they control so much of it, they keep a detailed records of information about the language on their developer site. Most information within this paper will be based upon those records. Unlike most languages, Swift has a very small set of syntax that needs to be shown compared to other languages.
    [Show full text]
  • LLVM Overview
    Overview Brandon Starcheus & Daniel Hackney Outline ● What is LLVM? ● History ● Language Capabilities ● Where is it Used? What is LLVM? What is LLVM? ● Compiler infrastructure used to develop a front end for any programming language and a back end for any instruction set architecture. ● Framework to generate object code from any kind of source code. ● Originally an acronym for “Low Level Virtual Machine”, now an umbrella project ● Intended to replace the GCC Compiler What is LLVM? ● Designed to be compatible with a broad spectrum of front ends and computer architectures. What is LLVM? LLVM Project ● LLVM (Compiler Infrastructure, our focus) ● Clang (C, C++ frontend) ● LLDB (Debugger) ● Other libraries (Parallelization, Multi-level IR, C, C++) What is LLVM? LLVM Project ● LLVM (Compiler Infrastructure, our focus) ○ API ○ llc Compiler: IR (.ll) or Bitcode (.bc) -> Assembly (.s) ○ lli Interpreter: Executes Bitcode ○ llvm-link Linker: Bitcode (.bc) -> Bitcode (.bc) ○ llvm-as Assembler: IR (.ll) -> Bitcode (.bc) ○ llvm-dis Disassembler: Bitcode (.bc) -> IR (.ll) What is LLVM? What is LLVM? Optimizations History History ● Developed by Chris Lattner in 2000 for his grad school thesis ○ Initial release in 2003 ● Lattner also created: ○ Clang ○ Swift ● Other work: ○ Apple - Developer Tools, Compiler Teams ○ Tesla - VP of Autopilot Software ○ Google - Tensorflow Infrastructure ○ SiFive - Risc-V SoC’s History Language Capabilities Language Capabilities ● Infinite virtual registers ● Strongly typed ● Multiple Optimization Passes ● Link-time and Install-time
    [Show full text]
  • Improving Program Reconstruction in LLDB Using C++ Modules
    Beyond Debug Information: Improving Program Reconstruction in LLDB using C++ Modules Master’s Thesis in Computer Science and Engineering RAPHAEL ISEMANN Department of Computer Science and Engineering CHALMERS UNIVERSITY OF TECHNOLOGY UNIVERSITY OF GOTHENBURG Gothenburg, Sweden 2019 Master’s thesis 2019 Beyond Debug Information: Improving Program Reconstruction in LLDB using C++ Modules Raphael Isemann Department of Computer Science and Engineering Chalmers University of Technology University of Gothenburg Gothenburg, Sweden 2019 Beyond Debug Information: Improving Program Reconstruction in LLDB using C++ Modules Raphael Isemann © Raphael Isemann, 2019. Supervisor: Thomas Sewell, Department of Computer Science and Engineering Examiner: Magnus Myreen, Department of Computer Science and Engineering Master’s Thesis 2019 Department of Computer Science and Engineering Chalmers University of Technology and University of Gothenburg SE-412 96 Gothenburg Telephone +46 31 772 1000 Cover: The LLVM logo, owned by and royality-free licensed from Apple Inc. Typeset in LATEX Gothenburg, Sweden 2019 iv Beyond Debug Information: Improving Program Reconstruction in LLDB using C++ Modules Raphael Isemann Department of Computer Science and Engineering Chalmers University of Technology and University of Gothenburg Abstract Expression evaluation is a core feature of every modern C++ debugger. Still, no C++ debugger currently features an expression evaluator that consistently supports advanced language features such as meta-programming with templates. The under- lying problem is that the debugger can often only partially reconstruct the debugged program from the debug information. This thesis presents a solution to this problem by using C++ modules as an additional source of program information. We devel- oped a prototype based on the LLDB debugger that is loading missing program components from the C++ modules used by the program.
    [Show full text]
  • Speed Performance Between Swift and Objective-C
    International Journal of Engineering Applied Sciences and Technology, 2016 Vol. 1, Issue 10, ISSN No. 2455-2143, Pages 185-189 Published Online August - September 2016 in IJEAST (http://www.ijeast.com) SPEED PERFORMANCE BETWEEN SWIFT AND OBJECTIVE-C Harwinder Singh Department of CSE DIET, Regional Centre PTU, Mohali, INDIA Abstracts: The appearance of a new programming Swift is a new programming language for iOS and OS X language gives the necessity to contrast its contribution apps that builds on the best of C and Objective-C, without with the existing programming languages to evaluate the the constraints of C compatibility. Swift adopts safe novelties and improvements that the new programming programming patterns and adds modern features to make language offers for developers. Intended to eventually programming easier, more flexible, and more fun. Swift’s replace Objective-C as Apple’s language of choice, Swift clean slate, backed by the mature and much loved Cocoa needs to convince developers to switch over to the new and Cocoa Touch frameworks, is an opportunity to language. Apple has promised that Swift will be faster reimaging how software development works. than Objective-C, as well as offer more modern language features, be very safe, and be easy to learn and use. In II. LITERATURE SURVEY this thesis developer test these claims by creating an iOS application entirely in Swift as well as benchmarking By Christ Lattner(2015)Released in June of 2014 by two different algorithms. Developer finds that while Apple Swift is a statically typed language and Swift is faster than Objective-C, it does not see the compiled language that uses the LLVM compiler speedup projected by Apple.
    [Show full text]
  • Xcode Static Analyzer
    1 Developer Tools Kickoff Session 300 Andreas Wendker These are confidential sessions—please refrain from streaming, blogging, or taking pictures 2 3 14 Billion Apps Downloaded 4 Xcode 4 Released March 2011 5 6 7 1 Single Window IB Inside Assistant Version Editor 8 1 Single Window LLVM Compiler 2 IB Inside Fix-It ImprovedBranchingLiveProjectAutomaticUnitSchemesAppArchivesCode QuickIssuesBehaviors Testing JumpValidation& Tabs Code & SnippetsTarget HelpMerging Provisioning Bar Completion Editor One-ClickC++WorkspacesLLDBSubversionGit inBlame LLVM Filtering Assistant Debugger Version Editor Instruments 9 LLVM Compiler 2 Schemes Improved Code Completion Automatic Provisioning Archives Debugger Single Window Subversion Branching & Merging Git Jump Bar IB Inside Version Editor Live Issues Behaviors LLDB Unit Testing Project & Target Editor Instruments Fix-It One-Click Filtering C++ in LLVM Blame Assistant Tabs Workspaces Quick Help App Validation Code Snippets 10 Smaller Free on Packages Lion Xcode in Mac App Store 11 Xcode 4.1 Xcode 4.2 12 Xcode 4.1 13 Built for Lion 14 15 Modernize Your Project 16 Assembly & Preprocessing 17 View-based tables New Cocoa controls Mac push notifications Entitlements Editor Custom behaviors 18 Auto Layout 19 Auto Layout Max Drukman 20 21 22 Demo 23 Xcode 4.2 24 Data Sync 25 Unit Tests 26 System Trace for iOS 27 Networking Activity 28 Simulate Locations 29 30 31 32 33 34 35 36 37 Storyboarding 38 Storyboarding Jon Hess 39 40 Scenes 41 SeguesScenes 42 43 Demo 44 45 OpenGL ES Performance Detective 46 OpenGL ES Analyzer
    [Show full text]
  • Reenix: Implementing a Unix-Like Operating System in Rust
    Reenix: Implementing a Unix-Like Operating System in Rust Alex Light (alexander [email protected]) Advisor: Tom Doeppner Reader: Shriram Krishnamurthi Brown University, Department of Computer Science April 2015 Abstract This paper describes the experience, problems and successes found in implementing a unix-like operating system kernel in rust. Using the basic design and much of the lowest-level support code from the Weenix operating system written for CS167/9 I was able to create a basic kernel supporting multiple kernel processes scheduled cooperatively, drivers for the basic devices and the beginnings of a virtual file system. I made note of where the rust programming language, and its safety and type systems, helped and hindered my work and made some, tentative, performance comparisons between the rust and C implementations of this kernel. I also include a short introduction to the rust programming language and the weenix project. Contents 1 Introduction 1 Introduction 1 Ever since it was first created in 1971 the UNIX operat- 1.1 The Weenix OS . .2 ing system has been a fixture of software engineering. 1.2 The Rust language . .2 One of its largest contributions to the world of OS engineering, and software engineering in general, was 2 Reenix 7 the C programming language created to write it. In 2.1 Organization . .7 the 4 decades that have passed since being released, C 2.2 Booting . .8 has changed relatively little but the state-of-the-art in 2.3 Memory & Initialization . .8 programming language design and checking, has ad- 2.4 Processes . .9 vanced tremendously.
    [Show full text]
  • Developer Tools #WWDC16
    Developer Tools #WWDC16 What’s New in Swift Session 402 Ted Kremenek Chris Lattner Ewa Matejska © 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Goals for Swift 3 Goals for Swift 3 Develop an open community Goals for Swift 3 Develop an open community Portability to new platforms Goals for Swift 3 Develop an open community Portability to new platforms Get the fundamentals right Goals for Swift 3 Develop an open community Portability to new platforms Get the fundamentals right Optimize for awesomeness Swift Adoption at Apple Swift Adoption at Apple Music Console Agents and Daemons Dock Dock Dock Bar at Bottom Mission Control LaunchPad Command-Tab Application Switcher Stacks Accelerated Two Up Dashboard Spaces Some of Notification System What Changed from El Capitan to Sierra? Most of Mission Control completely rewritten in Swift Accessibility engine completely rewritten in Swift Project Evolution Lines of code Project Evolution Lines of code Dock is ~200,000 lines of code Project Evolution Lines of code Dock is ~200,000 lines of code 2.5x more Swift code Project Evolution Lines of code Dock is ~200,000 lines of code 2.5x more Swift code 15% less code to rewrite the same functionality in Swift Project Evolution Lines of code Dock is ~200,000 lines of code 2.5x more Swift code 15% less code to rewrite the same functionality in Swift New features were added at the same time swift.org Swift Open Source Open evolution process Non-Apple contributors with direct commit access
    [Show full text]
  • A Differential Approach to Undefined Behavior
    1 A Differential Approach to Undefined Behavior Detection XI WANG, NICKOLAI ZELDOVICH, M. FRANS KAASHOEK, and ARMANDO SOLAR-LEZAMA, Massachusetts Institute of Technology This article studies undefined behavior arising in systems programming languages such as C/C++. Undefined behavior bugs lead to unpredictable and subtle systems behavior, and their effects can be further amplified by compiler optimizations. Undefined behavior bugs are present in many systems, including the Linux kernel and the Postgres database. The consequences range from incorrect functionality to missing security checks. This article proposes a formal and practical approach that finds undefined behavior bugs by finding “unstable code” in terms of optimizations that leverage undefined behavior. Using this approach, we introduce a new static checker called STACK that precisely identifies undefined behavior bugs. Applying STACK to widely used systems has uncovered 161 new bugs that have been confirmed and fixed by developers. Categories and Subject Descriptors: D.4.6 [Operating Systems]: Security and Protection; F.3.2 [Logics and Meanings of Programs]: Semantics of Programming Languages General Terms: Languages, Reliability, Security Additional Key Words and Phrases: Undefined behavior, compiler optimizations ACM Reference Format: Xi Wang, Nickolai Zeldovich, M. Frans Kaashoek, and Armando Solar-Lezama. 2015. A differential approach to undefined behavior detection. ACM Trans. Comput. Syst. 33, 1, Article 1 (March 2015), 29 pages. DOI: http://dx.doi.org/10.1145/2699678 1. INTRODUCTION Undefined behavior in systems programming languages is a dark side of systems pro- gramming. It introduces unpredictable systems behavior and has a significant impact on reliability and security. This article proposes a new approach that identifies unde- fined behavior by finding code fragments that have divergent behavior under different interpretations of the language specification.
    [Show full text]
  • Apple's New Language for Cocoa
    Swift Apple’s new Language for Cocoa Hi I’m Paul Wood I’m the Lead Developer @ Transmedia Creative Lab where I make shopping apps Swift Swift was released last monday at WWDC It’s really new and there is a lot more to be learned than what has been presented at WWDC If you have watched all the WWDC video on Swift and already read the Language book then you may have a head start on me. If you’ve gotten in to writing code you are also doing better than me I’m trying to make this presentation similar to the lectures I received in College about new languages, I took a programming languages course and had to break down nearly every popular language since ADA fast! modern! safe! interactive! To Apple Says Swift is these 4 things, and after reading all the published goodies out there I’m going to back up their claim ! Cocoa and Cocoa Touch! Build with LLVM compiler! Optimizer and Autovectorizer! We as Cocoaheads need to know how its going to be useful in our current projects and Apple has built with with Cocoa development in mind. Almost purely Cocoa development in mind. ! I’m going to talk about LLVM a little later ! But incase you forgot a optimizer takes your readable code and puts in better algorithms on your behalf and Autovectorizer helps you with multiple threading, parallel computing. ! Its complicated stuff but just remember that it is there to make Swift fast while also being readable and concise How will we use Swift? client-side / GUI applications not on the server � Replace some Scripts, Like AppleScript, Python or Ruby Swift is really all about Cocoa ! For right now I expect that developer will only work in Swift for client side Graphical user interface based applications ! Its not a scripting language, it doesn’t have an interpreter, it isn’t going to be replacing PHP or Ruby, There are very few tools in the language or the Cocoa libraries to get this on the server.
    [Show full text]
  • Lecture 3 Overview of the LLVM Compiler
    Lecture 3 Overview of the LLVM Compiler Substantial portions courtesy of Gennady Pekhimenko, Olatunji Ruwase, Chris Lattner, Vikram Adve, and David Koes Carnegie Mellon LLVM Compiler System • The LLVM Compiler Infrastructure - Provides reusable components for building compilers - Reduce the time/cost to build a new compiler - Build static compilers, JITs, trace-based optimizers, ... • The LLVM Compiler Framework - End-to-end compilers using the LLVM infrastructure - C and C++ are robust and aggressive: • Java, Scheme and others are in development - Emit C code or native code for X86, Sparc, PowerPC Carnegie Mellon 2 Three primary LLVM components • The LLVM Virtual Instruction Set - The common language- and target-independent IR - Internal (IR) and external (persistent) representation • A collection of well-integrated libraries - Analyses, optimizations, code generators, JIT compiler, garbage collection support, profiling, … • A collection of tools built from the libraries - Assemblers, automatic debugger, linker, code generator, compiler driver, modular optimizer, … Carnegie Mellon 3 Tutorial Overview • Introduction to the running example • LLVM C/C++ Compiler Overview - High-level view of an example LLVM compiler • The LLVM Virtual Instruction Set - IR overview and type-system • The Pass Manager • Important LLVM Tools - opt, code generator, JIT, test suite, bugpoint Carnegie Mellon 4 Running Example: Argument Promotion Consider use of by-reference parameters: int callee(const int &X) int callee(const int *X) { { return *X+1; // memory
    [Show full text]
  • Design and Implementation of a Tricore Backend for the LLVM Compiler Framework
    Design and Implementation of a TriCore Backend for the LLVM Compiler Framework Studienarbeit im Fach Informatik vorgelegt von Christoph Erhardt geboren am 14.11.1984 in Kronach Angefertigt am Department Informatik Lehrstuhl fur¨ Informatik 4 { Verteilte Systeme und Betriebssysteme Friedrich-Alexander-Universit¨at Erlangen-Nurnberg¨ Betreuer: Prof. Dr.-Ing. habil. Wolfgang Schr¨oder-Preikschat Dipl.-Inf. Fabian Scheler Beginn der Arbeit: 01. Dezember 2008 Ende der Arbeit: 01. September 2009 Hiermit versichere ich, dass ich die Arbeit selbstst¨andig und ohne Benutzung anderer als der angegebenen Quellen angefertigt habe und dass die Arbeit in gleicher oder ¨ahnlicher Form noch keiner anderen Prufungsbeh¨ ¨orde vorgelegen hat und von dieser als Teil einer Prufungsleistung¨ angenommen wurde. Alle Stellen, die dem Wortlaut oder dem Sinn nach anderen Werken entnommen sind, habe ich durch Angabe der Quelle als Entlehnung kenntlich gemacht. Erlangen, den 01. September 2009 Uberblick¨ Diese Arbeit beschreibt die Entwicklung und Implementierung eines neuen Backends fur¨ das LLVM-Compiler-Framework, um das Erzeugen von Maschinencode fur¨ die TriCore- Prozessorarchitektur zu erm¨oglichen. Die TriCore-Architektur ist eine fortschrittliche Plattform fur¨ eingebettete Systeme, welche die Merkmale eines Mikrocontrollers, einer RISC-CPU und eines digitalen Signal- prozessors auf sich vereint. Sie findet prim¨ar im Automobilbereich und anderen Echtzeit- systemen Verwendung und wird am Lehrstuhl fur¨ Verteilte Systeme und Betriebssysteme der Universit¨at Erlangen-Nurnberg¨ fur¨ diverse Forschungsprojekte eingesetzt. Bei LLVM handelt es sich um eine moderne Compiler-Infrastruktur, bei deren Ent- wurf besonderer Wert auf Modularit¨at und Erweiterbarkeit gelegt wurde. Aus diesem Grund findet LLVM zunehmend Verbreitung in den verschiedensten Projekten { von Codeanalyse-Werkzeugen uber¨ Just-in-time-Compiler bis hin zu vollst¨andigen Allzweck- Systemcompilern.
    [Show full text]