在发射的LLVM IR上执行了LLVM通行证



如果我使用cargo rustc -- --emit=llvm-ir编译,编译器将发射llvm ir。

这是Rust使用的LLVM通行证。在发射的IR上执行了什么LLVM(如果有的话(?

有什么方法可以指定在排放ir之前要执行的通过?

在发射的IR上执行了哪些LLVM(如果有的话(?

如果您使用的是夜间编译器,则可以使用-Z print-llvm-passes让LLVM打印运行的内容。我也建议通过-Z no-parallel-llvm-C codegen-units=1传递,以使输出更清洁且重复性降低。

$ rustc -C codegen-units=1 -Z no-parallel-llvm -Z print-llvm-passes 1.rs
Pass Arguments:  -tti -targetlibinfo -verify -ee-instrument
Target Transform Information
Target Library Information
  FunctionPass Manager
    Module Verifier
    Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
Pass Arguments:  -tti -assumption-cache-tracker -profile-summary-info -targetlibinfo -forceattrs -basiccg -always-inline
Target Transform Information
Assumption Cache Tracker
Profile summary info
Target Library Information
  ModulePass Manager
    Force set function attributes
    CallGraph Construction
    Call Graph SCC Pass Manager
      Inliner for always_inline functions
...

(-Z print-llvm-passes标志等于-C llvm-args=-debug-pass=Structure,它在稳定的Rustc上可用。但是,如果没有-Z no-parallel-llvm,输出就非常不可读。(


有什么方法可以指定在排放ir之前要执行的通过?

您可以使用-C passes参数附加其他通行证。您也可以使用-C no-prepopulate-passes清除默认优化通过。示例:

$ rustc -C passes=print-alias-sets 1.rs
Alias sets for function 'Alias sets for function '_ZN3std3sys4unix7process14process_common8ExitCode6as_i3217h65e06df78d6f4a47E':
_ZN3std2rt10lang_start17hd8fe8cd552faf2aaE':
...

最新更新