This is an archive of the discontinued LLVM Phabricator instance.

[IR] Make Module::setProfileSummary to replace an existing ProfileSummary flag.
ClosedPublic

Authored by hjyamauchi on May 13 2020, 12:30 PM.

Details

Summary

Module::setProfileSummary currently calls addModuelFlag. This prevents from
updating the ProfileSummary metadata in the module and results in a second
ProfileSummary added instead of replacing an existing one. I don't think this is
the expected behavior. It prevents updating the ProfileSummary and it does not
make sense to have more than one. To address this, add Module::setModuleFlag and
use it from setProfileSummary.

Diff Detail

Event Timeline

hjyamauchi created this revision.May 13 2020, 12:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2020, 12:30 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
wmi added a subscriber: wmi.May 18 2020, 12:12 PM
wmi added inline comments.
llvm/lib/IR/Module.cpp
361–362

It has some code similar as getModuleFlagsMetadata. Can they be shared?

davidxl added a reviewer: xur.May 19 2020, 9:26 AM

Can CS FDO profile summary coexist with regular summary?

hjyamauchi marked an inline comment as done.

Address comments.

Can CS FDO profile summary coexist with regular summary?

Yes, it uses a different key "CSProfileSummary". So it does not conflict with the regular summary.

xur added a comment.May 19 2020, 12:25 PM

I noticed the same issue when I implemented CSFDO -- I initially reused the same summary name for CSFDO as in FDO.
Exiting of two module flags with the same name sometime breaks the build (not always, if I remember correctly).

This fix looks to me.

This revision is now accepted and ready to land.May 20 2020, 12:29 PM
This revision was automatically updated to reflect the committed changes.