当前位置: X-MOL 学术arXiv.cs.PF › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Modeling the Invariance of Virtual Pointers in LLVM
arXiv - CS - Performance Pub Date : 2020-02-22 , DOI: arxiv-2003.04228
Piotr Padlewski, Krzysztof Pszeniczny and Richard Smith

Devirtualization is a compiler optimization that replaces indirect (virtual) function calls with direct calls. It is particularly effective in object-oriented languages, such as Java or C++, in which virtual methods are typically abundant. We present a novel abstract model to express the lifetimes of C++ dynamic objects and invariance of virtual table pointers in the LLVM intermediate representation. The model and the corresponding implementation in Clang and LLVM enable full devirtualization of virtual calls whenever the dynamic type is statically known and elimination of redundant virtual table loads in other cases. Due to the complexity of C++, this has not been achieved by any other C++ compiler so far. Although our model was designed for C++, it is also applicable to other languages that use virtual dispatch. Our benchmarks show an average of 0.8% performance improvement on real-world C++ programs, with more than 30% speedup in some cases. The implementation is already a part of the upstream LLVM/Clang and can be enabled with the -fstrict-vtable-pointers flag.

中文翻译:

在 LLVM 中对虚拟指针的不变性进行建模

去虚拟化是一种编译器优化,它用直接调用代替间接(虚拟)函数调用。它在面向对象的语言中特别有效,例如 Java 或 C++,其中虚拟方法通常很丰富。我们提出了一个新的抽象模型来表达 C++ 动态对象的生命周期和 LLVM 中间表示中虚拟表指针的不变性。Clang 和 LLVM 中的模型和相应实现在动态类型静态已知时启用虚拟调用的完全去虚拟化,并在其他情况下消除冗余虚拟表加载。由于 C++ 的复杂性,到目前为止,任何其他 C++ 编译器都无法实现这一点。虽然我们的模型是为 C++ 设计的,但它也适用于其他使用虚拟分派的语言。我们的基准测试显示,实际 C++ 程序的性能平均提高了 0.8%,在某些情况下速度提高了 30% 以上。该实现已经是上游 LLVM/Clang 的一部分,可以使用 -fstrict-vtable-pointers 标志启用。
更新日期:2020-03-10
down
wechat
bug