This is an archive of the discontinued LLVM Phabricator instance.

[Instrumentation] Share InstrumentationIRBuilder between TSan and SanCov
ClosedPublic

Authored by melver on May 5 2022, 1:12 PM.

Details

Summary

Factor our InstrumentationIRBuilder and share it between ThreadSanitizer
and SanitizerCoverage. Simplify its usage at the same time (use function
of passed Instruction or BasicBlock).

This class may be used in other instrumentation passes in future.

NFCI.

Diff Detail

Event Timeline

melver created this revision.May 5 2022, 1:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2022, 1:12 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
melver requested review of this revision.May 5 2022, 1:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2022, 1:12 PM
nickdesaulniers accepted this revision.May 5 2022, 1:27 PM
nickdesaulniers added inline comments.
llvm/include/llvm/Transforms/Instrumentation.h
18–24

If we're going to update the includes, please consider also including Function.h and Instruction.h.

203–212

Do we construct any IRBuilders with more than 1 arg?

Do we still need explicit if there's more than 1 arg?

This revision is now accepted and ready to land.May 5 2022, 1:27 PM
melver updated this revision to Diff 427444.May 5 2022, 2:07 PM
melver marked an inline comment as done.

Add includes.

llvm/include/llvm/Transforms/Instrumentation.h
203–212

Yeah, I wanted to try this on AddressSanitizer.cpp, where there are some. It's not used right now, but for completeness I felt I should add it. If you think we should only add the support when it's actually used, I can remove.

WDYT?

Yes, the explicit should stay for vararg constructors where there can only be 1 arg.

nickdesaulniers added inline comments.May 5 2022, 2:18 PM
llvm/include/llvm/Transforms/Instrumentation.h
203–212

Unless you're actively planning to do that port for asan soon (why not do it in this patch, too), I feel like YAGNI, but I also don't care enough either way, hence the approval. I bring it up only because I was wondering what was being used from <utility> (which is std::forward).

melver updated this revision to Diff 427533.May 5 2022, 11:52 PM
melver marked 2 inline comments as done.

Remove unneeded constructors (and <utility>) for now. Can add back later when
we need it.

llvm/include/llvm/Transforms/Instrumentation.h
203–212

Fair point.

I tried ASan just now, but requires a bit more care. I will try to get to it eventually. (FYI, in the kernel we have LTO depends on !KASAN, which is why nobody noticed - but if I remove that restriction, things break as expected.)

This revision was landed with ongoing or failed builds.May 6 2022, 12:15 AM
This revision was automatically updated to reflect the committed changes.