Home Page Icon
Home Page
Table of Contents for
LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries
Close
LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries
by
LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries
LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries
Contributors
About the author
About the reviewer
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Section 1: Build System and LLVM-Specific Tooling
Chapter 1: Saving Resources When Building LLVM
Technical requirements
Cutting down building resources with better tooling
Replacing GNU Make with Ninja
Avoiding the use of the BFD linker
Tweaking CMake arguments
Choosing the right build type
Avoiding building all targets
Building as shared libraries
Splitting the debug info
Building an optimized version of llvm-tblgen
Using the new PassManager and Clang
Using GN for a faster turnaround time
Summary
Further reading
Chapter 2: Exploring LLVM's Build System Features
Technical requirements
Exploring a glossary of LLVM's important CMake directives
Using the CMake function to add new libraries
Using the CMake function to add executables and tools
Using the CMake function to add Pass plugins
Understanding CMake integration for out-of-tree projects
Summary
Chapter 3: Testing with LLVM LIT
Technical requirements
Using LIT in out-of-tree projects
Preparing for our example project
Writing LIT configurations
LIT internals
Learning useful FileCheck tricks
Preparing for our example project
Writing FileCheck directives
Exploring the TestSuite framework
Preparing for our example project
Importing code into llvm-test-suite
Summary
Further reading
Chapter 4: TableGen Development
Technical requirements
Introduction to TableGen syntax
Layout and records
Bang operators
Multiclass
The DAG data type
Writing a donut recipe in TableGen
Printing a recipe via the TableGen backend
TableGen's high-level workflow
Writing the TableGen backend
Integrating the RecipePrinter TableGen backend
Summary
Further reading
Section 2: Frontend Development
Chapter 5: Exploring Clang's Architecture
Technical requirements
Learning Clang's subsystems and their roles
Driver
LLVM, assemblers, and linkers
Exploring Clang's tooling features and extension options
The FrontendAction class
Clang plugins
LibTooling and Clang Tools
Summary
Further reading
Chapter 6: Extending the Preprocessor
Technical requirements
Working with SourceLocation and SourceManager
Introducing SourceLocation
Introducing SourceManager
Learning preprocessor and lexer essentials
Understanding the role of the preprocessor and lexer in Clang
Understanding Token
Handling macros
Developing custom preprocessor plugins and callbacks
The project goal and preparation
Implementing a custom pragma handler
Implementing custom preprocessor callbacks
Summary
Exercises
Chapter 7: Handling AST
Technical requirements
Learning about AST in Clang
In-memory structure of Clang AST
Types in Clang AST
ASTMatcher
Writing AST plugins
Project overview
Printing diagnostic messages
Creating the AST plugin
Summary
Chapter 8: Working with Compiler Flags and Toolchains
Technical requirements
Understanding drivers and toolchains in Clang
Adding custom driver flags
Project overview
Declaring custom driver flags
Translating custom driver flags
Passing flags to the frontend
Adding a custom toolchain
Project overview
Creating the toolchain and adding a custom include path
Creating a custom assembling stage
Creating a custom linking stage
Verifying the custom toolchain
Summary
Exercises
Section 3: "Middle-End" Development
Chapter 9: Working with PassManager and AnalysisManager
Technical requirements
Writing an LLVM Pass for the new PassManager
Project overview
Writing the StrictOpt Pass
Working with the new AnalysisManager
Overview of the project
Writing the HaltAnalyzer Pass
Learning instrumentations in the new PassManager
Printing Pass pipeline details
Printing changes to the IR after each Pass
Bisecting the Pass pipeline
Summary
Questions
Chapter 10: Processing LLVM IR
Technical requirements
Learning LLVM IR basics
Iterating different IR units
Iterating instructions
Iterating basic blocks
Iterating the call graph
Learning about GraphTraits
Working with values and instructions
Understanding SSA
Working with values
Working with instructions
Working with loops
Learning about loop representation in LLVM
Learning about loop infrastructure in LLVM
Summary
Chapter 11: Gearing Up with Support Utilities
Technical requirements
Printing diagnostic messages
Collecting statistics
Using the Statistic class
Using an optimization remark
Adding time measurements
Using the Timer class
Collecting the time trace
Error-handling utilities in LLVM
Introducing the Error class
Learning about the Expected and ErrorOr classes
The Expected class
The ErrorOr class
Summary
Chapter 12: Learning LLVM IR Instrumentation
Technical requirements
Developing a sanitizer
An example of using an address sanitizer
Creating a loop counter sanitizer
Working with PGO
Introduction to instrumentation-based PGO
Introduction to sampling-based PGO
Using profiling data analyses
Summary
Assessments
Chapter 6, Extending the Preprocessor
Chapter 8, Working with Compiler Flags and Toolchains
Chapter 9, Working with PassManager and AnalysisManager
Why subscribe?
Other Books You May Enjoy
Packt is searching for authors like you
Leave a review - let other readers know what you think
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset