clang 和 llvm opt 中可用的优化列表

Ary*_* Mz 1 gcc g++ llvm clang

可以使用 .gcc/G++ 获取 GCC/G++ 中可用的优化器列表gcc --help=optimizers。合法值和参数范围也在 中定义params.defparams.defclang 也有这样的命令和文件吗?

Ami*_*mir 5

1-Clang使用:

clang -OX -mllvm -debug-pass=Arguments foo.c
Run Code Online (Sandbox Code Playgroud)

或者

clang -OX -mllvm -debug-pass=Structure foo.c
Run Code Online (Sandbox Code Playgroud)

哪里X可以Os,O1,O2,O3 and O4(-O4 等同于 -O3,除了它在从源文件发出编译目标文件LLVM IR而不是目标代码时执行 LTO(链接时间优化)这一事实)

您将有两套, Pass Arguments其中第一套是通行证global kernel,第二套是通行证function pass

2-Opt使用:

llvm-as < /dev/null | opt -OX -disable-output -debug-pass=Arguments
Run Code Online (Sandbox Code Playgroud)

X可以在哪里Os,O1,O2 and O3

从 LLVM-15x 开始更新

由于新的通行证管理器设置为默认通行证管理器,因此上面的答案仅打印legacy pass manager通行证。为了查看新的 pass manager 通过 opt 进行传递,请尝试:

opt --print-passes   "Print available passes that can be specified in -passes=foo and exit"
Run Code Online (Sandbox Code Playgroud)

或者

llvm-as < /dev/null | opt -OX --print-pipeline-passes    "Print a '-passes' compatible string describing the pipeline (best-effort only)"
Run Code Online (Sandbox Code Playgroud)