LLVM优化级别的含义 [英] Meaning of the LLVM Optimization Levels

查看:212
本文介绍了LLVM优化级别的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用Clang / LLVM,想知道是否有任何关于-Ox优化级别的特定文档?

I recently started working with Clang/LLVM and would like to know if there is any particular documentation on what the -Ox optimization levels do?

我在LLVM文档页面找不到任何东西。有人可以分享几个链接吗?

I couldn't find much on the LLVM documentation page. Can someone share a few links?

谢谢。

推荐答案

Clang的命令行选项文档确实很差,特别是你是正确的,几乎没有解释什么优化级别。

Clang's command-line options documentation is indeed very poor, and in particular you are correct that there's almost no explanation of what the optimizations level do.

但是,FreeBSD添加了有有用摘要的手册页

FreeBSD, however, does add a man page with a useful summary:


-O0 -O1 -O2 -Os -Oz -O3 -O4

指定要使用的优化级别。 -O0表示没有
优化:此级别编译最快并生成
最可调试代码。 -O2是一个中等优化水平
,它实现了大多数优化。 -Os类似于-O2和额外的
优化以减少代码大小。 -Oz像-Os(和-O2),
,但进一步减少代码大小。 -O3类似于-O2,除了它
可以执行需要更长时间执行的优化或可能
生成更大的代码(试图让程序运行
更快)。在支持的平台上,-O4启用链接时
优化;对象文件存储在LLVM位码文件
格式中,并且在链接时完成整个程序优化。 -O1是
,介于-O0和-O2之间。

-O0 -O1 -O2 -Os -Oz -O3 -O4
Specify which optimization level to use. -O0 means "no optimization": this level compiles the fastest and generates the most debuggable code. -O2 is a moderate level of optimization which enables most optimizations. -Os is like -O2 with extra optimizations to reduce code size. -Oz is like -Os (and thus -O2), but reduces code size further. -O3 is like -O2, except that it enables optimizations that take longer to perform or that may generate larger code (in an attempt to make the program run faster). On supported platforms, -O4 enables link-time optimization; object files are stored in the LLVM bitcode file format and whole program optimization is done at link time. -O1 is somewhere between -O0 and -O2.

如果您想查找通行证对每个优化执行,请参阅此Stackoverflow问题:

If you're looking to find the exact list of passes performed for each optimization, see this Stackoverflow question:

  • Clang optimization levels

这篇关于LLVM优化级别的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆