Skip to content

[DebuggingTheCompiler] Document a few flags for dumping llvm-ir. #34185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/DebuggingTheCompiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ benefit of all Swift developers.
- [Debugging the Compiler using advanced LLDB Breakpoints](#debugging-the-compiler-using-advanced-lldb-breakpoints)
- [Debugging the Compiler using LLDB Scripts](#debugging-the-compiler-using-lldb-scripts)
- [Custom LLDB Commands](#custom-lldb-commands)
- [Debugging at LLVM Level](#debugging-at-llvm-level)
- [Options for Dumping LLVM IR](#options-for-dumping-llvm-ir)
- [Bisecting Compiler Errors](#bisecting-compiler-errors)
- [Bisecting on SIL optimizer pass counts to identify optimizer bugs](#bisecting-on-sil-optimizer-pass-counts-to-identify-optimizer-bugs)
- [Using git-bisect in the presence of branch forwarding/feature branches](#using-git-bisect-in-the-presence-of-branch-forwardingfeature-branches)
Expand Down Expand Up @@ -537,6 +539,20 @@ to define custom commands using just other lldb commands. For example,

(lldb) command alias cs sequence p/x $rax; stepi

## Debugging at LLVM Level

### Options for Dumping LLVM IR

Similar to SIL, one can configure LLVM to dump the llvm-ir at various points in
the pipeline. Here is a quick summary of the various options:

* ``-Xllvm -print-before=$PASS_ID``: Print the LLVM IR before a specified LLVM pass runs.
* ``-Xllvm -print-before-all``: Print the LLVM IR before each pass runs.
* ``-Xllvm -print-after-all``: Print the LLVM IR after each pass runs.
* ``-Xllvm -filter-print-funcs=$FUNC_NAME_1,$FUNC_NAME_2,...,$FUNC_NAME_N``:
When printing IR for functions for print-[before|after]-all options, Only
print the IR for functions whose name is in this comma separated list.

## Bisecting Compiler Errors

### Bisecting on SIL optimizer pass counts to identify optimizer bugs
Expand Down