This is an archive of the discontinued LLVM Phabricator instance.

Implement `createSanitizerCtor`, common helper function for all sanitizers
ClosedPublic

Authored by ismailp on Apr 1 2015, 9:44 AM.

Details

Summary

This helper function creates a ctor function, which calls sanitizer's
init function with given arguments. This constructor is then expected
to be added to module's ctors. The patch helps unifying how sanitizer
constructor functions are created, and how init functions are called
across all sanitizers.

Diff Detail

Event Timeline

ismailp updated this revision to Diff 23069.Apr 1 2015, 9:44 AM
ismailp retitled this revision from to Implement `createSanitizerCtor`, common helper function for all sanitizers.
ismailp updated this object.
ismailp edited the test plan for this revision. (Show Details)
ismailp added reviewers: kcc, samsonov.
ismailp added a subscriber: Unknown Object (MLST).

Alexey, please review this while Kostya is away.

samsonov edited edge metadata.May 1 2015, 12:28 PM

Sorry for the late response.

include/llvm/Transforms/Utils/ModuleUtils.h
55

This function looks overly complicated to me. Essentially, you create *both* sanitizer initialization function,
and sanitizer module constructor here. Consider splitting this function into two functions. Or rename it accordingly
and return std::pair<Function *, Function *> to clearly indicate that you create two objects. Note that in the latter case
you will not need an overload.

56

I'd rather not provide the default argument values - passing {} explicitly is easy.

ismailp updated this revision to Diff 24862.May 2 2015, 3:16 PM
ismailp edited edge metadata.

Addressed comments:

  • Renamed function, and say that it creates both ctor and init functions
  • Returned a std::pair<Function *, Function *>
  • Removed default arguments
ismailp added inline comments.May 2 2015, 3:21 PM
include/llvm/Transforms/Utils/ModuleUtils.h
55

I used std::pair at my first attempt, but I didn't want to #include <utility>.

LGTM with a couple of nits.

include/llvm/Transforms/Utils/ModuleUtils.h
59

This is not really InitType, this is InitArgTypes, right?

lib/Transforms/Utils/ModuleUtils.cpp
112

assert that two ArrayRef's have equal size?

samsonov accepted this revision.May 5 2015, 10:59 AM
samsonov edited edge metadata.
This revision is now accepted and ready to land.May 5 2015, 10:59 AM

Thank you for your time!

include/llvm/Transforms/Utils/ModuleUtils.h
59

Yes, this is InitArgsType.

lib/Transforms/Utils/ModuleUtils.cpp
112

Yes, I will add assertion. But, IIRC, it is already done by CreateCall below. I have a vague recollection of such an assertion.

samsonov added inline comments.May 5 2015, 2:06 PM
include/llvm/Transforms/Utils/ModuleUtils.h
59

Please rename accordingly.

lib/Transforms/Utils/ModuleUtils.cpp
112

OK, feel free to disregard this.

This revision was automatically updated to reflect the committed changes.