This is an archive of the discontinued LLVM Phabricator instance.

Eliminate __llvm_profile_register calls
AbandonedPublic

Authored by davidxl on Sep 30 2015, 4:52 PM.

Details

Reviewers
bogner
rsmith
Summary

With PGO, the instrumented binary needs to dump llvm_prf_data, llvm_prf_cnts, and llvm_prf_names data sections. The runtime needs to figure out the start and end addresses of the sections. The way it is implemented for Linux is emit function calls during start up time to register the llvm_profile_data variables created for the functions, and runtime library tracks the start and end. On Darwin, special section symbol is used so this is avoided.

This is not only inefficient, but also wastes lots of space in text.

This patch proposes using linker script to solve the problem. The changes in clang FE is basically refactoring. The core changes are in projects/compiler_rt/profile and llvm.

Diff Detail

Event Timeline

davidxl updated this revision to Diff 36164.Sep 30 2015, 4:52 PM
davidxl retitled this revision from to Eliminate __llvm_profile_register calls .
davidxl updated this object.
davidxl added reviewers: bogner, rsmith.
davidxl added subscribers: cfe-commits, llvm-commits.

With this patch, 11M bytes (text section) can be shaved off clang build with instrumentation.

rsmith edited edge metadata.Sep 30 2015, 5:30 PM

Clang changes LGTM.

rsmith added inline comments.Sep 30 2015, 5:50 PM
lib/Driver/ToolChains.cpp
2191–2193

Please add a driver test for this change.

davidxl abandoned this revision.Sep 30 2015, 6:41 PM

Will split the patch into 3.