Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
97cf461b
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97cf461b
编写于
11月 19, 2021
作者:
A
Axel Cohen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a codegen option to allow loading LLVM pass plugins
上级
4a7fb971
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
30 addition
and
1 deletion
+30
-1
compiler/rustc_codegen_llvm/src/back/write.rs
compiler/rustc_codegen_llvm/src/back/write.rs
+4
-0
compiler/rustc_codegen_llvm/src/llvm/ffi.rs
compiler/rustc_codegen_llvm/src/llvm/ffi.rs
+2
-0
compiler/rustc_codegen_ssa/src/back/write.rs
compiler/rustc_codegen_ssa/src/back/write.rs
+4
-0
compiler/rustc_interface/src/tests.rs
compiler/rustc_interface/src/tests.rs
+1
-0
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+17
-1
compiler/rustc_session/src/options.rs
compiler/rustc_session/src/options.rs
+2
-0
未找到文件。
compiler/rustc_codegen_llvm/src/back/write.rs
浏览文件 @
97cf461b
...
...
@@ -470,6 +470,8 @@ pub(crate) unsafe fn optimize_with_new_llvm_pass_manager(
let
extra_passes
=
config
.passes
.join
(
","
);
let
pass_plugins
=
config
.pass_plugins
.join
(
" "
);
// FIXME: NewPM doesn't provide a facility to pass custom InlineParams.
// We would have to add upstream support for this first, before we can support
// config.inline_threshold and our more aggressive default thresholds.
...
...
@@ -499,6 +501,8 @@ pub(crate) unsafe fn optimize_with_new_llvm_pass_manager(
selfprofile_after_pass_callback
,
extra_passes
.as_ptr
()
.cast
(),
extra_passes
.len
(),
pass_plugins
.as_ptr
()
.cast
(),
pass_plugins
.len
(),
);
result
.into_result
()
.map_err
(|()|
llvm_err
(
diag_handler
,
"failed to run LLVM passes"
))
}
...
...
compiler/rustc_codegen_llvm/src/llvm/ffi.rs
浏览文件 @
97cf461b
...
...
@@ -2304,6 +2304,8 @@ pub fn LLVMRustOptimizeWithNewPassManager(
end_callback
:
SelfProfileAfterPassCallback
,
ExtraPasses
:
*
const
c_char
,
ExtraPassesLen
:
size_t
,
PassPlugins
:
*
const
c_char
,
PassPluginsLen
:
size_t
,
)
->
LLVMRustResult
;
pub
fn
LLVMRustPrintModule
(
M
:
&
'a
Module
,
...
...
compiler/rustc_codegen_ssa/src/back/write.rs
浏览文件 @
97cf461b
...
...
@@ -74,6 +74,8 @@ pub enum BitcodeSection {
pub
struct
ModuleConfig
{
/// Names of additional optimization passes to run.
pub
passes
:
Vec
<
String
>
,
/// Paths of LLVM pass plugins to load.
pub
pass_plugins
:
Vec
<
String
>
,
/// Some(level) to optimize at a certain level, or None to run
/// absolutely no optimizations (used for the metadata module).
pub
opt_level
:
Option
<
config
::
OptLevel
>
,
...
...
@@ -170,6 +172,8 @@ fn new(
ModuleConfig
{
passes
:
if_regular!
(
sess
.opts.cg.passes
.clone
(),
vec!
[]),
pass_plugins
:
if_regular!
(
sess
.opts.cg.pass_plugins
.clone
(),
vec!
[]),
opt_level
:
opt_level_and_size
,
opt_size
:
opt_level_and_size
,
...
...
compiler/rustc_interface/src/tests.rs
浏览文件 @
97cf461b
...
...
@@ -587,6 +587,7 @@ fn test_codegen_options_tracking_hash() {
tracked!
(
overflow_checks
,
Some
(
true
));
tracked!
(
panic
,
Some
(
PanicStrategy
::
Abort
));
tracked!
(
passes
,
vec!
[
String
::
from
(
"1"
),
String
::
from
(
"2"
)]);
tracked!
(
pass_plugins
,
vec!
[
String
::
from
(
"1"
),
String
::
from
(
"2"
)]);
tracked!
(
prefer_dynamic
,
true
);
tracked!
(
profile_generate
,
SwitchWithOptPath
::
Enabled
(
None
));
tracked!
(
profile_use
,
Some
(
PathBuf
::
from
(
"abc"
)));
...
...
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
浏览文件 @
97cf461b
...
...
@@ -17,6 +17,7 @@
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Passes/StandardInstrumentations.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/FileSystem.h"
...
...
@@ -753,7 +754,8 @@ LLVMRustOptimizeWithNewPassManager(
void
*
LlvmSelfProfiler
,
LLVMRustSelfProfileBeforePassCallback
BeforePassCallback
,
LLVMRustSelfProfileAfterPassCallback
AfterPassCallback
,
const
char
*
ExtraPasses
,
size_t
ExtraPassesLen
)
{
const
char
*
ExtraPasses
,
size_t
ExtraPassesLen
,
const
char
*
PassPlugins
,
size_t
PassPluginsLen
)
{
Module
*
TheModule
=
unwrap
(
ModuleRef
);
TargetMachine
*
TM
=
unwrap
(
TMRef
);
OptimizationLevel
OptLevel
=
fromRust
(
OptLevelRust
);
...
...
@@ -924,6 +926,20 @@ LLVMRustOptimizeWithNewPassManager(
}
}
if
(
PassPluginsLen
)
{
auto
PluginsStr
=
StringRef
(
PassPlugins
,
PassPluginsLen
);
SmallVector
<
StringRef
>
Plugins
;
PluginsStr
.
split
(
Plugins
,
' '
,
-
1
,
false
);
for
(
auto
PluginPath
:
Plugins
)
{
auto
Plugin
=
PassPlugin
::
Load
(
PluginPath
.
str
());
if
(
!
Plugin
)
{
LLVMRustSetLastError
((
"Failed to load pass plugin"
+
PluginPath
.
str
()).
c_str
());
continue
;
}
Plugin
->
registerPassBuilderCallbacks
(
PB
);
}
}
#if LLVM_VERSION_GE(13, 0)
ModulePassManager
MPM
;
#else
...
...
compiler/rustc_session/src/options.rs
浏览文件 @
97cf461b
...
...
@@ -1033,6 +1033,8 @@ mod parse {
"panic strategy to compile crate with"
),
passes
:
Vec
<
String
>
=
(
Vec
::
new
(),
parse_list
,
[
TRACKED
],
"a list of extra LLVM passes to run (space separated)"
),
pass_plugins
:
Vec
<
String
>
=
(
Vec
::
new
(),
parse_list
,
[
TRACKED
],
"a list of LLVM pass plugins to load (space separated)"
),
prefer_dynamic
:
bool
=
(
false
,
parse_bool
,
[
TRACKED
],
"prefer dynamic linking to static linking (default: no)"
),
profile_generate
:
SwitchWithOptPath
=
(
SwitchWithOptPath
::
Disabled
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录