This is an archive of the discontinued LLVM Phabricator instance.

Part 2 of Fine tune MachineFunctionSplitPass (MFS) for FSAFDO.
ClosedPublic

Authored by shenhan on Jun 9 2023, 12:31 PM.

Details

Summary

This is a follow up to D152399.

This CL adds a new discriminator pass. Also adds a new sample profile pass when MFS is enabled.

Also includes tests for both FSAFDO-MFS and FSADO pass config.

Diff Detail

Event Timeline

shenhan created this revision.Jun 9 2023, 12:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 12:31 PM
shenhan requested review of this revision.Jun 9 2023, 12:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 12:31 PM
xur added inline comments.Jun 9 2023, 1:10 PM
llvm/lib/CodeGen/TargetPassConfig.cpp
1250

It seems that you use Pass3 to replace PassLast. Should we use PassLast here? This way we can still save Pass3 for others.
I don't think we will have other discriminator pass after this.

1288

The intention here is to use FSAFDO with improved discriminator for MFS.
I would suggest a warning (or even a hard error) here if we detect otherwise AFDO mode is used.
This would helpful to user mistakes (especially that we know MFS + AFDO can degrade the performance).

If we commit this patch before D152399 then I think we can move the machine-function-splitter-fsafdo.ll test to D152399? It would be nice to keep the patch and it's own test in the same commit.

shenhan updated this revision to Diff 530090.Jun 9 2023, 3:02 PM
shenhan marked an inline comment as done.
shenhan added inline comments.
llvm/lib/CodeGen/TargetPassConfig.cpp
1250

Agree. Replaced Pass3 with PassLast.

1288

Yes. Added a check for sample_profile+fs_discriminator must both present.

xur accepted this revision.Jul 5 2023, 2:09 PM

LGTM.

This revision is now accepted and ready to land.Jul 5 2023, 2:09 PM
hoy added inline comments.Jul 5 2023, 2:36 PM
llvm/lib/CodeGen/TargetPassConfig.cpp
1289

A fatal error seems too strong to me. Can we do a warning instead so that we can still experiment with non-FS AutoFDO profile?

wenlei added inline comments.Jul 5 2023, 2:36 PM
llvm/lib/CodeGen/TargetPassConfig.cpp
1228

Is this FSNoFinalDiscrim cl flag still used anywhere? Remove fs-no-final-discrim to cleanup?

wenlei added inline comments.Jul 5 2023, 2:38 PM
llvm/lib/CodeGen/TargetPassConfig.cpp
1289

Agree. There is no correctness issue, and sub-optimal performance doesn't justify a fatal.

xur added inline comments.Jul 5 2023, 2:57 PM
llvm/lib/CodeGen/TargetPassConfig.cpp
1228

Good catch. I don't think there is a use for the var. We should remove that option.

1289

I'm fine with a warning too.

shenhan updated this revision to Diff 538874.Jul 10 2023, 5:00 PM
shenhan marked 5 inline comments as done.
shenhan added inline comments.
llvm/lib/CodeGen/TargetPassConfig.cpp
1228

Deleted.

1289

Done by reporting warning only.

wenlei accepted this revision.Jul 10 2023, 5:21 PM

lgtm, thanks.

This revision was landed with ongoing or failed builds.Jul 11 2023, 10:41 PM
This revision was automatically updated to reflect the committed changes.