This is an archive of the discontinued LLVM Phabricator instance.

[CSSPGO] Warn instead of error out for modules that are not probed.
ClosedPublic

Authored by hoy on Dec 13 2021, 9:25 AM.

Details

Summary

Modules that are not compiled with pseudo probe enabled can still be compiled with a sample profile input, such as in LTO postlink where other modules are probed. Since the profile is unrelated to the current modules, we should warn instead of error out the compilation.

Diff Detail

Event Timeline

hoy created this revision.Dec 13 2021, 9:25 AM
hoy requested review of this revision.Dec 13 2021, 9:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2021, 9:25 AM

Modules that are not compiled with pseudo probe enabled can reference functions that are probed, cause those functions imported into the non-probed module.

If module is not compiled with probe, we would run into problem even if there's no importing at all, right? The problem seems to be that we're loading csspgo profile (have a valid reader) for that module without probe.

The purpose of the original change it to make sure csspgo is always 100% effective, and if not, we should fix the build. With this change, how do we make sure that is still the case? i.e. we can now pass csspgo profile to a build without adding pseudo-probe flag, and the build will still succeed, right?

hoy added a comment.Dec 13 2021, 10:13 AM

Modules that are not compiled with pseudo probe enabled can reference functions that are probed, cause those functions imported into the non-probed module.

If module is not compiled with probe, we would run into problem even if there's no importing at all, right? The problem seems to be that we're loading csspgo profile (have a valid reader) for that module without probe.

Modules not compiled with probe should not have its functions show up in the profile, thus the profile file will not be loaded and the error should not be triggered. The case I was seeing that triggered the error is due to imported modules and it only failed in thinlto postlink. This can be fixed by always importing probe desc for importing modules. However, we've decided not to do that to favor build time.

The purpose of the original change it to make sure csspgo is always 100% effective, and if not, we should fix the build. With this change, how do we make sure that is still the case? i.e. we can now pass csspgo profile to a build without adding pseudo-probe flag, and the build will still succeed, right?

Yes, in this case the build will still succeed with the warnings. The build may not be easy to fix when the modules not probes are not compiled with clang, say Rust. If we want the build to be blocked, what we could do is to add a fancy check here against non-imported functions for now. What do you think?

Modules not compiled with probe should not have its functions show up in the profile, thus the profile file will not be loaded and the error should not be triggered.

My point is that modules not compiled with probe should not have fprofile-sample-use at all. If fprofile-sample-use is specified and csspgo profile is used, then we expect probe flag to be on too. Is that assumption not true? That is the underlying problem I'm getting at.

hoy added a comment.EditedDec 13 2021, 10:23 PM

Modules not compiled with probe should not have its functions show up in the profile, thus the profile file will not be loaded and the error should not be triggered.

My point is that modules not compiled with probe should not have fprofile-sample-use at all. If fprofile-sample-use is specified and csspgo profile is used, then we expect probe flag to be on too. Is that assumption not true? That is the underlying problem I'm getting at.

Right, they currently do not have the profile passed in during clang compilation, ie. LTO prelink, as far as I see. What failed for me was LTO postlink, where the profile was shared by all modules. So in your case, the failure happened in prelink?

wenlei accepted this revision.Dec 14 2021, 4:24 PM

Modules not compiled with probe should not have its functions show up in the profile, thus the profile file will not be loaded and the error should not be triggered.

My point is that modules not compiled with probe should not have fprofile-sample-use at all. If fprofile-sample-use is specified and csspgo profile is used, then we expect probe flag to be on too. Is that assumption not true? That is the underlying problem I'm getting at.

Right, they currently do not have the profile passed in during clang compilation, ie. LTO prelink, as far as I see. What failed for me was LTO postlink, where the profile was shared by all modules. So in your case, the failure happened in prelink?

Ok, can you update the description then? It doesn't seem related to importing. It's an error with some modules for the same LTO build not having probe flag, but still using the same csspgo profile at post link.

This revision is now accepted and ready to land.Dec 14 2021, 4:24 PM
hoy edited the summary of this revision. (Show Details)Dec 14 2021, 4:36 PM
This revision was landed with ongoing or failed builds.Dec 14 2021, 4:39 PM
This revision was automatically updated to reflect the committed changes.