A core design principle of C++ is that users should only incur costs for features they actually use, both in terms of performance and code size. A notable exception to this rule is the run-time type information (RTTI) data, used for dynamic downcasts, exceptions, and run-time type introspection.
For classes that define at least one virtual method, compilers generate RTTI data that uniquely identifies the type, including a string for the type name. In large programs with complex type inheritance hierarchies, this RTTI data can grow substantially in size. Moreover, dynamic casting algorithms are linear in the type hierarchy size, causing some programs to spend considerable time on these casts. The common workaround is to use the -fno-rtti compiler flag, which disables RTTI data generation. However, this approach has significant drawbacks, such as disabling polymorphic exceptions and dynamic casts, and requiring the flag to be applied across the entire program due to ABI changes.
In this paper, we propose a new link-time optimization to mitigate both the performance and size overhead associated with dynamic casts and RTTI data. Our optimization replaces costly library calls for downcasts with short instruction sequences and eliminates unnecessary RTTI data by modifying vtables to remove RTTI slots. Our prototype, implemented in the LLVM compiler, demonstrates an average of 1.4%, as well as an average binary size reduction of 1.7%.
Fri 20 JunDisplayed time zone: Seoul change
10:30 - 12:10 | Compilers 2PLDI Research Papers at Grand Ball Room 2 Chair(s): Michel Steuwer Technische Universität Berlin | ||
10:30 20mTalk | Robustifying Debug Information Updates in LLVM via Control-Flow Conformance Analysis PLDI Research Papers Shan Huang East China Normal University, Jingjing Liang East China Normal University, Ting Su East China Normal University, Qirun Zhang Georgia Institute of Technology DOI | ||
10:50 20mTalk | CompCertOC: Verified Compositional Compilation of Multi-threaded Programs with Shared Stacks PLDI Research Papers Ling Zhang Shanghai Jiao Tong University, Yuting Wang Shanghai Jiao Tong University, Yalun Liang Shanghai Jiao Tong University, Zhong Shao Yale University DOI | ||
11:10 20mTalk | Link-Time Optimization of Dynamic Casts in C++ Programs PLDI Research Papers Xufan Lu INESC-ID / Instituto Superior Técnico, University of Lisbon, Nuno P. Lopes INESC-ID; Instituto Superior Técnico - University of Lisbon Link to publication DOI | ||
11:30 20mTalk | Divergence-Aware Testing of Graphics Shader Compiler Back-Ends PLDI Research Papers Dongwei Xiao Hong Kong University of Science and Technology, Shuai Wang Hong Kong University of Science and Technology, Zhibo Liu Hong Kong University of Science and Technology, Yiteng Peng Hong Kong University of Science and Technology, Daoyuan Wu Hong Kong University of Science and Technology, Zhendong Su ETH Zurich DOI | ||
11:50 20mTalk | Optimization-Directed Compiler Fuzzing for Continuous Translation Validation PLDI Research Papers DOI Pre-print |