This is an archive of the discontinued LLVM Phabricator instance.

[CGProfile] don't emit cgprofile entry if called function is dllimport
ClosedPublic

Authored by zequanwu on Sep 22 2020, 6:11 PM.

Diff Detail

Event Timeline

zequanwu created this revision.Sep 22 2020, 6:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2020, 6:11 PM
zequanwu requested review of this revision.Sep 22 2020, 6:11 PM
rnk added a comment.Sep 23 2020, 3:12 PM

I think this is reasonable. There is no need to record call graph profile edges from functions to imported functions in the metadata. However, I would prefer to move the check into CodeGen, so that if we receive some IR that has edges like this, we don't emit an object file that cannot be linked. I'd be OK doing the check in both places.

In D88127#2291167, @rnk wrote:

However, I would prefer to move the check into CodeGen, so that if we receive some IR that has edges like this, we don't emit an object file that cannot be linked.

I think we just want to do it here, simply don't generate the "CG Profile" metadata entry for dllimport function, since the IR could complied to assembly or object file. Otherwise, we need two checks in both MCAsmStreamer and MCCOFFStreamer.

rnk added a comment.Sep 23 2020, 4:14 PM

I'm saying the fix belongs in TargetObjectFileLoweringImpl.cpp, which is the point where we translate from IR to assembly. We can't fix this after producing assembly, because we don't know what symbols are marked dllimport at that point.

In D88127#2291320, @rnk wrote:

I'm saying the fix belongs in TargetObjectFileLoweringImpl.cpp, which is the point where we translate from IR to assembly. We can't fix this after producing assembly, because we don't know what symbols are marked dllimport at that point.

That's reverted. (https://reviews.llvm.org/rG91aed9bf975f1e4346cc8f4bdefc98436386ced2). I don't know if I should put two patches together.

rnk added a comment.Sep 23 2020, 4:52 PM

That's reverted. (https://reviews.llvm.org/rG91aed9bf975f1e4346cc8f4bdefc98436386ced2). I don't know if I should put two patches together.

Well, normally code that has been reverted cannot be relanded without changes, so it's common to revert the revert locally, edit it, and reupload it for code review. I believe you can even "reopen" the closed code review issue that you used for the first review, and it will show the changes you made clearly.

rnk accepted this revision.Sep 23 2020, 4:53 PM

In any case, if you want to do that separately, I think this change stands on its own, so I will approve it as is.

This revision is now accepted and ready to land.Sep 23 2020, 4:53 PM
This revision was landed with ongoing or failed builds.Sep 23 2020, 4:57 PM
This revision was automatically updated to reflect the committed changes.