This is an archive of the discontinued LLVM Phabricator instance.

[FS-AFDO] Load pseudo probe profile on MIR
ClosedPublic

Authored by hoy on Apr 17 2023, 4:54 PM.

Details

Summary

This change enables loading pseudo-probe based profile on MIR. Different from the IR profile loader, callsites are excluded from MIR profile loading since they are not assinged a FS discriminator. Using zero as the discriminator is not accurate and would undo the distribution work done by the IR loader based on pseudo probe distribution factor. We reply on block probes only for FS profile loading.

Some refactoring is done to the IR profile loader so that getProbeWeight can be shared by both loaders.

Diff Detail

Event Timeline

hoy created this revision.Apr 17 2023, 4:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2023, 4:54 PM
hoy requested review of this revision.Apr 17 2023, 4:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2023, 4:54 PM
hoy updated this revision to Diff 518480.May 1 2023, 10:01 AM

Updating D148584: [FS-AFDO] Load pseudo probe profile on MIR

wenlei added inline comments.May 8 2023, 6:36 PM
llvm/include/llvm/IR/PseudoProbe.h
102

does this need 64-bit?

hoy added inline comments.May 9 2023, 1:07 PM
llvm/include/llvm/IR/PseudoProbe.h
102

not necessary. Changed to 32 bit.

hoy updated this revision to Diff 520799.May 9 2023, 1:07 PM

Updating D148584: [FS-AFDO] Load pseudo probe profile on MIR

wenlei added inline comments.May 10 2023, 9:56 AM
llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
235 ↗(On Diff #520799)

what change caused these discriminator diffs? I thought only the first patch in the stack could affect this.

hoy added inline comments.May 10 2023, 10:07 AM
llvm/test/Transforms/SampleProfile/pseudo-probe-profile-mismatch.ll
235 ↗(On Diff #520799)

Yeah, with the first patch there should be no probes on the IR with non-zero discriminators initially, so I'm cleaning up here.

The change should be belong to the first patch. I can move it over there. It shouldn't be needed by this patch.

hoy updated this revision to Diff 521030.May 10 2023, 10:29 AM

Moving a test change to previous patch.

lgtm, thanks.

llvm/lib/CodeGen/MIRSampleProfile.cpp
111

So we don't do FS profile loading for call probes because discriminator on call probe is already occupied for probe id, hence call probe effectively doesn't have FS discriminator?

wenlei accepted this revision.May 10 2023, 10:45 AM
This revision is now accepted and ready to land.May 10 2023, 10:45 AM
hoy added inline comments.May 10 2023, 10:48 AM
llvm/lib/CodeGen/MIRSampleProfile.cpp
111

Exactly. We are relying on block probes only to get a FS count for basic blocks.

hoy updated this revision to Diff 521037.May 10 2023, 10:48 AM

Fixing a incrPGO test failure after rebasing.

This revision was landed with ongoing or failed builds.May 10 2023, 11:34 AM
This revision was automatically updated to reflect the committed changes.