LTO for Clang是否可以跨C和C ++方法进行优化 [英] Can LTO for clang optimize across C and C++ methods

查看:114
本文介绍了LTO for Clang是否可以跨C和C ++方法进行优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果链接时间优化(LTO)与 clang 一起使用,是否可能

If link-time optimization (LTO) is being used with clang, is it possible that code can be optimized across the C and C++ language boundary?

例如,可以将C函数内联到C ++调用程序中吗,或者反之亦然?

For example, can a C function be inlined into a C++ caller, or vice-versa?

推荐答案

AFAIK,是的,因为Clang生成LLVM中间表示,并且LTO发生在该LLVM字节码上。

AFAIK, yes since Clang produces LLVM intermediate representation, and LTO happens on that LLVM bytecode.

BTW任何类型的链接时间优化发生在某些 (已编译代码)的中间表示形式,而不仅仅是机器代码上的< a href = https://en.wikipedia.org/wiki/Relocation_(computing) rel = nofollow noreferrer>重定位,如每个目标文件进行操作。 LTO,无论使用什么表示形式(GCC中的GIMPLE,Clang中的LLVM)都在添加并使用这些额外信息(这就是为什么目标文件变得更胖的原因)。

BTW any kind of link-time-optimization happens on some intermediate representation (of the compiled code), not just on machine code with relocation, as kept in every object file. LTO, whatever representation is used (GIMPLE in GCC, LLVM in Clang) is adding and using such extra information (and that is why the object files become fatter).

这篇关于LTO for Clang是否可以跨C和C ++方法进行优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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