Commit 1b3a5f2
committed
Auto merge of #91125 - eskarn:llvm-passes-plugin-support, r=nagisa
Allow loading LLVM plugins with both legacy and new pass manager
Opening a draft PR to get feedback and start discussion on this feature. There is already a codegen option `passes` which allow giving a list of LLVM pass names, however we currently can't use a LLVM pass plugin (as described here : https://llvm.org/docs/WritingAnLLVMPass.html), the only available passes are the LLVM built-in ones.
The proposed modification would be to add another codegen option `pass-plugins`, which can be set with a list of paths to shared library files. These libraries are loaded using the LLVM function `PassPlugin::Load`, which calls the expected symbol `lvmGetPassPluginInfo`, and register the pipeline parsing and optimization callbacks.
An example usage with a single plugin and 3 passes would look like this in the `.cargo/config`:
```toml
rustflags = [
"-C", "pass-plugins=/tmp/libLLVMPassPlugin",
"-C", "passes=pass1 pass2 pass3",
]
```
This would give the same functionality as the opt LLVM tool directly integrated in rust build system.
Additionally, we can also not specify the `passes` option, and use a plugin which inserts passes in the optimization pipeline, as one could do using clang.File tree
6 files changed
+58
-27
lines changed- compiler
- rustc_codegen_llvm/src
- back
- llvm
- rustc_codegen_ssa/src/back
- rustc_llvm/llvm-wrapper
6 files changed
+58
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
599 | | - | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
600 | 603 | | |
601 | 604 | | |
602 | 605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | 419 | | |
435 | 420 | | |
436 | 421 | | |
| |||
473 | 458 | | |
474 | 459 | | |
475 | 460 | | |
| 461 | + | |
| 462 | + | |
476 | 463 | | |
477 | 464 | | |
478 | 465 | | |
| |||
502 | 489 | | |
503 | 490 | | |
504 | 491 | | |
| 492 | + | |
| 493 | + | |
505 | 494 | | |
506 | 495 | | |
507 | 496 | | |
| |||
530 | 519 | | |
531 | 520 | | |
532 | 521 | | |
533 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
534 | 526 | | |
535 | 527 | | |
536 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2313 | 2313 | | |
2314 | 2314 | | |
2315 | 2315 | | |
| 2316 | + | |
| 2317 | + | |
2316 | 2318 | | |
2317 | 2319 | | |
2318 | 2320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| |||
411 | 417 | | |
412 | 418 | | |
413 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
| 264 | + | |
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
753 | 754 | | |
754 | 755 | | |
755 | 756 | | |
756 | | - | |
| 757 | + | |
| 758 | + | |
757 | 759 | | |
758 | 760 | | |
759 | 761 | | |
| |||
924 | 926 | | |
925 | 927 | | |
926 | 928 | | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
927 | 943 | | |
928 | 944 | | |
929 | 945 | | |
| |||
0 commit comments