This is an archive of the discontinued LLVM Phabricator instance.

[esan|cfrag] Instrument GEP instr for struct field access.
ClosedPublic

Authored by zhaoqin on Jun 1 2016, 6:27 PM.

Details

Summary

Instrument GEP instruction for counting the number of struct field
address calculation to approximate the number of struct field accesses.

Adds test struct_field_count_basic.ll to test the struct field
instrumentation.

Diff Detail

Repository
rL LLVM

Event Timeline

zhaoqin updated this revision to Diff 59328.Jun 1 2016, 6:27 PM
zhaoqin retitled this revision from to [esan|cfrag] Instrument GEP instr for struct field access..
zhaoqin updated this object.
zhaoqin added reviewers: aizatsky, bruening.
zhaoqin added subscribers: bruening, kcc, vitalybuka and 3 others.
junbuml added a subscriber: junbuml.Jun 2 2016, 6:43 AM
zhaoqin updated this revision to Diff 59442.Jun 2 2016, 12:19 PM

Rebase to ToT and resolve conflicts

aizatsky added inline comments.Jun 2 2016, 1:47 PM
lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
329 ↗(On Diff #59442)

Will this grow and grow in huge lto programs? Is this a concern?

613 ↗(On Diff #59442)

It is not clear to me why this map would contain this source element type at all. Wouldn't this work only for structs defined in the same module?

616 ↗(On Diff #59442)

Do you need counters for how many accesses were skipped?

zhaoqin marked an inline comment as done.Jun 2 2016, 3:34 PM
zhaoqin added inline comments.
lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
329 ↗(On Diff #59442)

This StructTyMap should be fairly small esp if separate compilation.

If there is any concern, that would be that we have one struct counter array for each struct type and we rely on the linker to merge them based on their name, xref createStructCounterName.
Another concern is the runtime hash map for holding each struct type counter.
I would expect the total number of different struct/class types won't be an insane number.

613 ↗(On Diff #59442)

I assume that StructTyMap would have that type (i.e, struct type is in M.getIdentifiedStructTypes()) if the GEP instr knows how to calculate the field offset within the struct.

616 ↗(On Diff #59442)

add NumIgnoredGEPs and NumInstrumentedGEPs.

zhaoqin updated this revision to Diff 59468.Jun 2 2016, 3:35 PM
zhaoqin marked an inline comment as done.

Add NumIgnoredGEPs and NumInstrumentedGEPs.

aizatsky accepted this revision.Jun 2 2016, 3:44 PM
aizatsky edited edge metadata.
aizatsky added inline comments.
lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
615 ↗(On Diff #59468)

Ack. getIdentifiedStructTypes uses TypeFinder and walks over the tree.

This revision is now accepted and ready to land.Jun 2 2016, 3:44 PM
This revision was automatically updated to reflect the committed changes.