This is an archive of the discontinued LLVM Phabricator instance.

[InstrProf][NFC] Save profile bias to function map
ClosedPublic

Authored by ellis on Nov 20 2021, 10:17 AM.

Details

Summary

Add a map from functions to load instructions that compute the profile bias. Previously we assumed that if the first instruction in the function was a load instruction, then it must be computing the bias. This was likely to work out because functions usually start with the llvm.instrprof.increment instruction, but optimizations could change this. For example, inlining into a non-profiled function.

Diff Detail

Event Timeline

ellis created this revision.Nov 20 2021, 10:17 AM
ellis updated this revision to Diff 388714.Nov 20 2021, 10:18 AM

Run clang-format.

ellis published this revision for review.Nov 22 2021, 9:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 22 2021, 9:18 AM

Thanks, alternative solution we've implemented in D114383 is to name the load instruction and then check the name before reusing it, but this solution is more precise.

phosek accepted this revision.May 13 2022, 11:20 AM

LGTM

@ellis do you have time to land this change? This change should address https://github.com/llvm/llvm-project/issues/55125 so I'd like to see it landed.

llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
61

I'd prefer FunctionToProfileBiasMap to be consistent with other variables like ProfileDataMap.

This revision is now accepted and ready to land.May 13 2022, 11:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 11:20 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
ellis added a comment.May 16 2022, 7:03 AM

LGTM

@ellis do you have time to land this change? This change should address https://github.com/llvm/llvm-project/issues/55125 so I'd like to see it landed.

Sure, I'll try to land this now!

ellis updated this revision to Diff 429719.May 16 2022, 8:06 AM

Rename function map and rebase

ellis updated this revision to Diff 429724.May 16 2022, 8:32 AM
ellis marked an inline comment as done.

Rebase

This revision was landed with ongoing or failed builds.May 16 2022, 8:32 AM
This revision was automatically updated to reflect the committed changes.
ellis added a comment.May 16 2022, 8:35 AM

@phosek I've landed this, but it does not seem to fix https://github.com/llvm/llvm-project/issues/55125

I believe the error is related to -do-counter-promotion since setting that to false makes the crash go away. I'll comment in the github issue.