This is an archive of the discontinued LLVM Phabricator instance.

[PGO] Create the profile data variable before the lowering
ClosedPublic

Authored by xur on Jan 8 2016, 3:21 PM.

Details

Summary

This patch creates the profile data variable before lowering the profile intrinsics (i.e. InstrProfIncrementInst and InstrProfValueProfileInst).

This is for IR level instrumentation. Lowering InstrProfValueProfileInst assumes the existing of profile data variable. For clang based instrumentation, we always see InstrProfIncrementInst before the first InstrProfValueProfileInst. But this is not true for IR level instrumeatnion (as we may not instrument the entry BB).

Diff Detail

Repository
rL LLVM

Event Timeline

xur updated this revision to Diff 44382.Jan 8 2016, 3:21 PM
xur retitled this revision from to [PGO] Create the profile data variable before the lowering.
xur updated this object.
xur added reviewers: davidxl, silvas, bogner.
xur added a subscriber: llvm-commits.
davidxl added inline comments.Jan 8 2016, 3:29 PM
lib/Transforms/Instrumentation/InstrProfiling.cpp
155 ↗(On Diff #44382)

Why not fuse this loop with the above one?

betulb added a subscriber: betulb.Jan 12 2016, 11:38 AM
betulb added inline comments.
lib/Transforms/Instrumentation/InstrProfiling.cpp
158 ↗(On Diff #44382)

if (!CounterVarSet) in the above line is redundant.

xur updated this revision to Diff 45026.Jan 15 2016, 1:14 PM

Changed the patch based on comments.

davidxl added inline comments.Jan 15 2016, 1:33 PM
lib/Transforms/Instrumentation/InstrProfiling.cpp
141 ↗(On Diff #45026)

Remove the comments here.

154 ↗(On Diff #45026)

Why is this flag needed?

161 ↗(On Diff #45026)

Add a brief comment here: Value profiling intrinsic lowering requires per-function profile data variable to be created first.

xur updated this revision to Diff 45033.Jan 15 2016, 1:48 PM

revised patch based on David's comments.

davidxl accepted this revision.Jan 15 2016, 1:50 PM
davidxl edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 15 2016, 1:50 PM
silvas edited edge metadata.Jan 15 2016, 4:27 PM

LGTM with a nit.

lib/Transforms/Instrumentation/InstrProfiling.cpp
152 ↗(On Diff #45033)

Cast the result to void to indicate that we are throwing away the return value of this function (i.e. we are only calling it for the side effects).

This revision was automatically updated to reflect the committed changes.