This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] emit CG profile for COFF object file
ClosedPublic

Authored by zequanwu on Sep 16 2020, 7:06 PM.

Diff Detail

Event Timeline

zequanwu created this revision.Sep 16 2020, 7:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2020, 7:06 PM
zequanwu requested review of this revision.Sep 16 2020, 7:06 PM
zequanwu updated this revision to Diff 292686.Sep 17 2020, 6:08 PM

test case.

zequanwu edited the summary of this revision. (Show Details)Sep 17 2020, 6:08 PM
rnk accepted this revision.Sep 18 2020, 10:48 AM

lgtm!

I see the assembler support is already there, looks like it works.

This revision is now accepted and ready to land.Sep 18 2020, 10:48 AM
This revision was automatically updated to reflect the committed changes.
rnk added inline comments.Sep 22 2020, 2:31 PM
llvm/lib/Target/TargetLoweringObjectFile.cpp
164

I had to revert this change in rG90242caca2074dab5a9b76e5bc36d9fafd2179a7. I think the fix might be to return null if the call graph edge target is marked dllimport here.

zequanwu added inline comments.Sep 22 2020, 2:43 PM
llvm/lib/Target/TargetLoweringObjectFile.cpp
164

I was thinking about a discussion in https://reviews.llvm.org/D81775?id=270540#inline-751699, which might be the cause. I was trying to do the same as ELF. Not sure if that's the cause.

zequanwu reopened this revision.Sep 23 2020, 4:57 PM
This revision is now accepted and ready to land.Sep 23 2020, 4:57 PM
zequanwu updated this revision to Diff 293899.Sep 23 2020, 5:09 PM

Update. Don't emit CGProfileEntry if function has dll import storage class.

rnk accepted this revision.Sep 24 2020, 2:20 PM

lgtm

llvm/lib/Target/TargetLoweringObjectFile.cpp
165

Thanks! You can see the diff here if you are curious:
https://reviews.llvm.org/D87811?vs=292846&id=293899#toc

This revision was automatically updated to reflect the committed changes.
zequanwu reopened this revision.Sep 28 2020, 3:04 PM
This revision is now accepted and ready to land.Sep 28 2020, 3:04 PM
zequanwu updated this revision to Diff 294817.EditedSep 28 2020, 3:06 PM

For symbols haven't seen, just set them to external not weak external.

Previously I did it that way, because http://llvm.org/docs/Extensions.html#sht-llvm-call-graph-profile-section-call-graph-profile says

If either symbol is undefined, then that symbol is defined as if .weak symbol has been written at the end of the file.

zequanwu added inline comments.Sep 28 2020, 3:09 PM
llvm/lib/MC/MCWinCOFFStreamer.cpp
344

It's meaningless to set symbol to WeakExternal and External at same time here. At the end, the symbol just become WeakExternal.

rnk added a comment.Sep 28 2020, 4:53 PM

Can you remove the weak external marking in a separate change from relanding? It changes existing functionality of the .cg_profile directive, so it can be committed independently, which is nice for making changes as small and independent as possible.

zequanwu updated this revision to Diff 294839.Sep 28 2020, 5:19 PM

Split changes on .cg_profile to another patch D88456.

Can we have a separate NFC refactor commit, to move that lump of code into its own emitCGProfile method? It might make the functional bits easier to follow. Also we have a private change in that area, and the ping-pong for this change has been a real headache.

zequanwu updated this revision to Diff 295077.Sep 29 2020, 12:02 PM

Will put the refactor part to a separate NFC commit.
Reland this as fix at D88456 seems work. (https://bugs.chromium.org/p/chromium/issues/detail?id=1130780#c18)

This revision was landed with ongoing or failed builds.Sep 29 2020, 12:03 PM
This revision was automatically updated to reflect the committed changes.