This is an archive of the discontinued LLVM Phabricator instance.

[SampleFDO] Make FSDiscriminator flag part of function parameters
ClosedPublic

Authored by xur on Jun 18 2021, 6:19 PM.

Details

Summary

dd a parameter of IsFSDiscriminator to function
getBaseDiscriminator(), and
getBaseDiscriminatorFromDiscriminator().

Both functions currently check internal flag of
--enable-fs-discriminator. This is not good because we might
change the default value of the internal flag.

Note that we have a default parameter in
getBaseDiscriminatorFromDiscriminator(). This is just
because that the create_afdo_tool has a call-site to it.
I will remove the default parameter in a later patch.

This is pretty much NFC.

Diff Detail

Event Timeline

xur created this revision.Jun 18 2021, 6:19 PM
xur requested review of this revision.Jun 18 2021, 6:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 18 2021, 6:19 PM
xur updated this revision to Diff 353272.Jun 20 2021, 10:48 PM

Sent a wrong patch.
This is the patch I wanted to send for review.

wmi added inline comments.Jun 21 2021, 8:38 AM
llvm/include/llvm/IR/DebugInfoMetadata.h
2202–2205

Can we just use "unsigned DILocation::getBaseDiscriminator(bool IsFSDiscriminator = false)" or we still need the two API?

xur added inline comments.Jun 21 2021, 10:31 AM
llvm/include/llvm/IR/DebugInfoMetadata.h
2202–2205

Note that one still checks the option of enable-fs-discrminator. And the other uses a flag (when we know for sure the format).
If we just keep one, we will probably keep the one without parameters.

If we want to use the one with default (false) parameters, we need to set the options in many callers.

wenlei accepted this revision.Jun 21 2021, 11:30 AM

lgtm.

llvm/include/llvm/IR/DebugInfoMetadata.h
2202–2205

This is indeed somewhat redundant. Understand that with two functions, we avoid changing many call sites, but it's probably cleaner to unify (default to false, pass EnableFSDiscriminator from callers when needed). I don't have a strong opinion.

llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
284

This seems to be the most important change in the patch? :)

This revision is now accepted and ready to land.Jun 21 2021, 11:30 AM
wenlei added inline comments.Jun 21 2021, 12:25 PM
llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
284

Pasting email reply from Rong:

No. It's actually NFC in this patch. This is because this code is currently only called by ProfileLoader. In ProfileLoader, getDiscriminator() is the same as getBaseDiscriminator() because only base discriminator is used.
This only matters for FS-ProfileLoader.

Just to make sure I understand this correctly, this path will be shared between base/current profile loader and fs-profile loader, right?

xur updated this revision to Diff 353469.Jun 21 2021, 1:04 PM

Integrated Wenlei's suggestion to remove the redundant interface.

hoy accepted this revision.Jun 21 2021, 1:20 PM

LGTM.