This is an archive of the discontinued LLVM Phabricator instance.

Build SymbolMap in SampleProfileLoader to help matchin function names with suffix.
ClosedPublic

Authored by danielcdh on Apr 11 2017, 11:19 AM.

Details

Summary

If there is suffix added in the function name (e.g. module hash added by thinLTO), we will not be able to find a match in profile as the suffix does not exist in profile. This patch build a map from function name to Function *. The map includes the entry for the stripped function name so that inlineHotFunctions can find the corresponding function to promote/inline.

Event Timeline

danielcdh created this revision.Apr 11 2017, 11:19 AM
davidxl added inline comments.Apr 17 2017, 2:23 PM
lib/Transforms/IPO/SampleProfile.cpp
1439

Why erasing the existing entry?

danielcdh updated this revision to Diff 95493.Apr 17 2017, 2:33 PM

add comment

danielcdh marked an inline comment as done.Apr 17 2017, 2:33 PM
danielcdh added inline comments.
lib/Transforms/IPO/SampleProfile.cpp
1439

Updated the comment to explain why we remove the existing entry.

davidxl added inline comments.Apr 17 2017, 2:37 PM
lib/Transforms/IPO/SampleProfile.cpp
1439

but the new entry is not inserted either here. Should it just reset r.second = F? Also In presence of conflict, how do we know which one to pick?

danielcdh updated this revision to Diff 95499.Apr 17 2017, 2:54 PM
danielcdh marked an inline comment as done.

update

lib/Transforms/IPO/SampleProfile.cpp
1439

When there is conflict, we shall set the corresponding symbolmap entry to nullptr to avoid promoting random target.
Updated the code and test.

davidxl accepted this revision.Apr 17 2017, 3:00 PM

ok. The original erase is fine (given the intention is to discard cases with conflicts).

lgtm

This revision is now accepted and ready to land.Apr 17 2017, 3:00 PM
danielcdh closed this revision.Apr 17 2017, 3:35 PM