This is an archive of the discontinued LLVM Phabricator instance.

[esan|cfrag] Add struct info registration
ClosedPublic

Authored by zhaoqin on May 24 2016, 12:28 PM.

Details

Summary

Adds StructInfo to CacheFragInfo to match the LLVM's EfficiencySanitizer
structs.

Uses StructHashMap to keep track of the struct info used by the app.

Adds registerStructInfo/unregisterStructInfo to add/remove struct infos
to/from StructHashMap.

updates test struct-simple.cpp with more C structs.

Diff Detail

Event Timeline

zhaoqin updated this revision to Diff 58292.May 24 2016, 12:28 PM
zhaoqin retitled this revision from to [esan|cfrag] Add struct infomation printing for the cfrag tool..
zhaoqin updated this object.
zhaoqin added a reviewer: aizatsky.
zhaoqin added subscribers: kubamracek, bruening, kcc and 4 others.
aizatsky added inline comments.May 24 2016, 3:01 PM
lib/esan/cache_frag.cpp
39

Not sure about this, but maybe add "print" member methods to structs?

41

why (uptr) casts?

filcab added a subscriber: filcab.May 25 2016, 9:36 AM

LGTM, with the fixes.

lib/esan/cache_frag.cpp
34

No need to have Ty in the name.

36

Maybe put the u32 at the end?
It'll end up being the same wasted space, but it might be easier to extend and keep binary compatibility, if we want (unsure we'd want that, though).

39

+1

zhaoqin added inline comments.May 25 2016, 8:55 PM
lib/esan/cache_frag.cpp
34

It was from my habit of using struct name_t in C.
Removed.

36

Why u32 at the end would keep binary compatibility? Won't anything append after won't change this layout? The only benefit I can see is some potential space saving in the future.

Adding ToolType back to ToolInfo/CacheFragInfo would be the most likely change in the future, and it would break any compatibility, so I won't worry too much about this.

39

I am not sure if I want to add anything to the struct created from the ESan pass.
It may increase the chance that the struct layout defined in the runtime is different from the struct layout defined in the compiler.
I would rather delete this routine as it is mainly for debugging.

41

From other examples.

lib/sanitizer_common/sanitizer_common.h:INLINE int Verbosity() {
lib/sanitizer_common/sanitizer_common.h: if ((uptr)Verbosity() >= (level)) Report(VA_ARGS); \
lib/sanitizer_common/sanitizer_common.h: if ((uptr)Verbosity() >= (level)) Printf(VA_ARGS); \

zhaoqin updated this revision to Diff 58562.May 25 2016, 9:49 PM

[esan|cfrag] Add struct info registration

zhaoqin retitled this revision from [esan|cfrag] Add struct infomation printing for the cfrag tool. to [esan|cfrag] Add struct info registration.May 25 2016, 9:51 PM
zhaoqin updated this object.
filcab accepted this revision.May 26 2016, 9:23 AM
filcab added a reviewer: filcab.

LGTM with a pass of clang-format.

lib/esan/cache_frag.cpp
24

Why u32 at the end would keep binary compatibility?

Would be easier to add fields (up to 4 bytes added) after the u32 and still fit in the same size. (Only valid because we know exactly how ABIs work on the platforms we support).
You can still add stuff using padding bytes with the u32 being where it is, so no big deal there.

Since this sanitizer is much more complicated than something like UBSan (where we pulled off changing the structures emitted once (twice after a revision in process gets accepted)), I don't think we should worry about this too much. OK as it is.

113

Please run clang-format on the patch.

This revision is now accepted and ready to land.May 26 2016, 9:23 AM
aizatsky accepted this revision.May 26 2016, 3:04 PM
aizatsky edited edge metadata.
zhaoqin updated this revision to Diff 59238.Jun 1 2016, 9:33 AM
zhaoqin edited edge metadata.

Update according to D20661

This revision was automatically updated to reflect the committed changes.