Skip to content

Commit 053c37f

Browse files
committed
Add README for -debug-pass-list feature
1 parent e1f7b3a commit 053c37f

File tree

1 file changed

+105
-32
lines changed

1 file changed

+105
-32
lines changed

README.md

Lines changed: 105 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,117 @@
1-
# The LLVM Compiler Infrastructure
1+
# LLVM Project
22

3-
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/llvm/llvm-project/badge)](https://securityscorecards.dev/viewer/?uri=github.com/llvm/llvm-project)
4-
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8273/badge)](https://www.bestpractices.dev/projects/8273)
5-
[![libc++](https://github.com/llvm/llvm-project/actions/workflows/libcxx-build-and-test.yaml/badge.svg?branch=main&event=schedule)](https://github.com/llvm/llvm-project/actions/workflows/libcxx-build-and-test.yaml?query=event%3Aschedule)
3+
## Introduction
64

7-
Welcome to the LLVM project!
5+
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Despite its name, LLVM has little to do with traditional virtual machines. The name "LLVM" itself is not an acronym; it is the full name of the project.
86

9-
This repository contains the source code for LLVM, a toolkit for the
10-
construction of highly optimized compilers, optimizers, and run-time
11-
environments.
7+
LLVM is an umbrella project that includes:
8+
- LLVM Core libraries (optimizer, code generators, etc.)
9+
- Clang: A C/C++/Objective-C compiler frontend
10+
- LLDB: A debugger
11+
- lld: A linker
12+
- And many other subprojects
1213

13-
The LLVM project has multiple components. The core of the project is
14-
itself called "LLVM". This contains all of the tools, libraries, and header
15-
files needed to process intermediate representations and convert them into
16-
object files. Tools include an assembler, disassembler, bitcode analyzer, and
17-
bitcode optimizer.
14+
## Prerequisites
1815

19-
C-like languages use the [Clang](https://clang.llvm.org/) frontend. This
20-
component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode
21-
-- and from there into object files, using LLVM.
16+
To build LLVM, you'll need:
2217

23-
Other components include:
24-
the [libc++ C++ standard library](https://libcxx.llvm.org),
25-
the [LLD linker](https://lld.llvm.org), and more.
18+
- A C++17 compatible compiler (GCC ≥ 7.1.0, Clang ≥ 5.0.0, Apple Clang ≥ 10.0.0, MSVC ≥ 19.14)
19+
- CMake ≥ 3.13.4
20+
- Python ≥ 3.6
21+
- Git (for version control)
22+
- Ninja build system (recommended) or GNU Make
2623

27-
## Getting the Source Code and Building LLVM
24+
On macOS, you can install the required tools with:
25+
```bash
26+
brew install cmake ninja python
27+
```
2828

29-
Consult the
30-
[Getting Started with LLVM](https://llvm.org/docs/GettingStarted.html#getting-the-source-code-and-building-llvm)
31-
page for information on building and running LLVM.
29+
## Building LLVM
3230

33-
For information on how to contribute to the LLVM project, please take a look at
34-
the [Contributing to LLVM](https://llvm.org/docs/Contributing.html) guide.
31+
### Basic Build Instructions
3532

36-
## Getting in touch
33+
1. Clone the repository (if you haven't already):
34+
```bash
35+
git clone https://github.com/llvm/llvm-project.git
36+
cd llvm-project
37+
```
3738

38-
Join the [LLVM Discourse forums](https://discourse.llvm.org/), [Discord
39-
chat](https://discord.gg/xS7Z362),
40-
[LLVM Office Hours](https://llvm.org/docs/GettingInvolved.html#office-hours) or
41-
[Regular sync-ups](https://llvm.org/docs/GettingInvolved.html#online-sync-ups).
39+
2. Create a build directory:
40+
```bash
41+
mkdir build
42+
cd build
43+
```
4244

43-
The LLVM project has adopted a [code of conduct](https://llvm.org/docs/CodeOfConduct.html) for
44-
participants to all modes of communication within the project.
45+
3. Configure with CMake:
46+
```bash
47+
cmake -G Ninja ../llvm \
48+
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld" \
49+
-DCMAKE_BUILD_TYPE=Release \
50+
-DLLVM_ENABLE_ASSERTIONS=ON
51+
```
52+
53+
Note: Adjust the `-DLLVM_ENABLE_PROJECTS` parameter to include only the subprojects you need.
54+
55+
4. Build:
56+
```bash
57+
ninja
58+
```
59+
60+
5. (Optional) Install:
61+
```bash
62+
ninja install
63+
```
64+
65+
### Using the New Pass Manager
66+
67+
LLVM has transitioned to a new pass manager. When using tools like `opt`, use the new syntax:
68+
69+
```bash
70+
# New pass manager syntax
71+
./bin/opt -passes=instcombine,reassociate -debug-pass-manager -disable-output test.ll
72+
73+
# Old syntax (deprecated)
74+
# ./bin/opt -instcombine -reassociate -debug-pass=List -disable-output test.ll
75+
```
76+
77+
## Documentation
78+
79+
For more detailed information, refer to the official LLVM documentation:
80+
81+
- [LLVM Documentation](https://llvm.org/docs/)
82+
- [Getting Started with LLVM](https://llvm.org/docs/GettingStarted.html)
83+
- [Building LLVM with CMake](https://llvm.org/docs/CMake.html)
84+
- [LLVM Programmer's Manual](https://llvm.org/docs/ProgrammersManual.html)
85+
- [New Pass Manager](https://llvm.org/docs/NewPassManager.html)
86+
87+
## License
88+
89+
LLVM is available under the [Apache License v2.0 with LLVM Exceptions](https://llvm.org/LICENSE.txt).
90+
91+
-----------------------------------------------------------------------------------------------------------
92+
93+
# LLVM with -debug-pass-list Feature (New Pass Manager)
94+
95+
This is a fork of the [official LLVM Project](https://github.com/llvm/llvm-project) focused on implementing an experimental `-debug-pass-list` command-line option for the New Pass Manager (NPM).
96+
97+
## Feature: -debug-pass-list
98+
99+
This feature provides a simple, flat list of pass names invoked by the New Pass Manager for a given optimization level. It's intended to be a more beginner-friendly way to see the sequence of operations compared to more verbose options.
100+
101+
### How to Use
102+
(Assuming you have built this version of Clang/LLVM)
103+
104+
With `clang`:
105+
```bash
106+
./bin/clang -O2 -mllvm -debug-pass-list your_file.c -o /dev/null
107+
# Or to avoid linker issues during testing:
108+
# ./bin/clang -O2 -mllvm -debug-pass-list -S your_file.c -o /dev/null
109+
110+
111+
112+
with opt:
113+
# First generate LLVM IR:
114+
# ./bin/clang -O2 -S -emit-llvm your_file.c -o your_file.ll
115+
116+
# Then run opt:
117+
./bin/opt -passes='default<O2>' -debug-pass-list -disable-output your_file.ll

0 commit comments

Comments
 (0)