Skip to content

Commit 6d599ea

Browse files
authored
Merge pull request #34185 from gottesmm/pr-2fab41ee8cd610aa53f2b2f7af6e7cf4113c9000
[DebuggingTheCompiler] Document a few flags for dumping llvm-ir.
2 parents 6651f6e + e7761cf commit 6d599ea

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/DebuggingTheCompiler.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ benefit of all Swift developers.
3030
- [Debugging the Compiler using advanced LLDB Breakpoints](#debugging-the-compiler-using-advanced-lldb-breakpoints)
3131
- [Debugging the Compiler using LLDB Scripts](#debugging-the-compiler-using-lldb-scripts)
3232
- [Custom LLDB Commands](#custom-lldb-commands)
33+
- [Debugging at LLVM Level](#debugging-at-llvm-level)
34+
- [Options for Dumping LLVM IR](#options-for-dumping-llvm-ir)
3335
- [Bisecting Compiler Errors](#bisecting-compiler-errors)
3436
- [Bisecting on SIL optimizer pass counts to identify optimizer bugs](#bisecting-on-sil-optimizer-pass-counts-to-identify-optimizer-bugs)
3537
- [Using git-bisect in the presence of branch forwarding/feature branches](#using-git-bisect-in-the-presence-of-branch-forwardingfeature-branches)
@@ -537,6 +539,20 @@ to define custom commands using just other lldb commands. For example,
537539

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

542+
## Debugging at LLVM Level
543+
544+
### Options for Dumping LLVM IR
545+
546+
Similar to SIL, one can configure LLVM to dump the llvm-ir at various points in
547+
the pipeline. Here is a quick summary of the various options:
548+
549+
* ``-Xllvm -print-before=$PASS_ID``: Print the LLVM IR before a specified LLVM pass runs.
550+
* ``-Xllvm -print-before-all``: Print the LLVM IR before each pass runs.
551+
* ``-Xllvm -print-after-all``: Print the LLVM IR after each pass runs.
552+
* ``-Xllvm -filter-print-funcs=$FUNC_NAME_1,$FUNC_NAME_2,...,$FUNC_NAME_N``:
553+
When printing IR for functions for print-[before|after]-all options, Only
554+
print the IR for functions whose name is in this comma separated list.
555+
540556
## Bisecting Compiler Errors
541557

542558
### Bisecting on SIL optimizer pass counts to identify optimizer bugs

0 commit comments

Comments
 (0)