This is an archive of the discontinued LLVM Phabricator instance.

Add Call Graph Profile pass and ELF assembly support
AbandonedPublic

Authored by Bigcheese on Jan 17 2018, 12:30 AM.

Details

Summary

This adds the LLVM side of https://reviews.llvm.org/D36351.

The purpose of this patch is to get call graph edge counts from LLVM IR to the linker.

The IR pass uses Block Frequency Info to generate module flags metadata in the format:

!28 = !{i32 5, !"CG Profile", !29}
!29 = !{!30, !31, !32, !33, !34, !35}
!30 = !{!"main", !"_Z3foov", i64 1}
!31 = !{!"main", !"_Z3barv", i64 1}
!32 = !{!"_Z3foov", !"_Z5adenav", i64 6}
!33 = !{!"_Z3foov", !"puts", i64 1}
!34 = !{!"_Z3barv", !"puts", i64 1}
!35 = !{!"_Z5adenav", !"puts", i64 10}

Where !28 is the modules flag for call graph profile info whose 3rd element is a list of (from name, to name, count) triplets.

This data is then written to the object file in the .note.llvm.cgprofile section as an array of:

uint32_t: From Symbol Index
uint32_t: To Symbol Index
uint64_t: Call Count

This also adds the .cg_profile directive to the assembly parser/printer as:

.cg_profile <from symbol name>, <to symbol name>, <call count>

Which generates the above triplets.

I've yet to write non-lld tests for this, and I'll do so before commit.

Diff Detail

Repository
rL LLVM

Event Timeline

Bigcheese created this revision.Jan 17 2018, 12:30 AM
Bigcheese abandoned this revision.Mar 29 2018, 12:46 PM

Has this review been abandoned? If so, is there any other tooling to generate CG profile input to lld from an iPGO profile?

Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2019, 11:11 AM