This is an archive of the discontinued LLVM Phabricator instance.

[ArgumentPromotion]: Copy function metadata after promoting arguments
ClosedPublic

Authored by etiotto on Aug 26 2020, 8:29 AM.

Details

Summary

The argument promotion pass currently fails to copy function annotations over to the modified function after promoting arguments.
This patch copies the original function annotation to the new function.

Diff Detail

Event Timeline

etiotto created this revision.Aug 26 2020, 8:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2020, 8:29 AM
etiotto requested review of this revision.Aug 26 2020, 8:29 AM
fhahn added inline comments.Aug 26 2020, 9:07 AM
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
220–222

That should not be necessary anymore now that we copy all the metadata?

One thing we need to keep in mind is that the original function may not be deleted and there are some kinds of metadata that need to be unique per function (.e.g !dbg), hence the F->setSubprogram(nullptr) below. With the change, it might be good to add a comment why we need to remove the !dbg metadata from the original function. But I am not aware of any other metadata nodes that have a similar constraint.

etiotto updated this revision to Diff 288335.Aug 27 2020, 8:01 AM

Fix quotes in profile.ll

etiotto marked an inline comment as done.Aug 27 2020, 9:29 AM
etiotto added inline comments.
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
220–222

Good point. I'll drop this line and add the comment you suggested.

etiotto updated this revision to Diff 288366.Aug 27 2020, 9:30 AM
etiotto marked an inline comment as done.

Address code review comments.

fhahn accepted this revision.Sep 1 2020, 7:50 AM

LGTM, thanks! For the commit message, I think saying 'copy function metadata' instead of 'function annotations' is more accurate. Also there seems to be a stray : in the title.

This revision is now accepted and ready to land.Sep 1 2020, 7:50 AM
etiotto retitled this revision from [ArgumentPromotion]: Copy function annotation after promoting arguments to [ArgumentPromotion]: Copy function metadata after promoting arguments.Sep 2 2020, 7:20 AM