This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Simplify and future-proof maybeMarkSanitizerLibraryCallNoBuiltin().
ClosedPublic

Authored by eugenis on Jul 27 2016, 5:18 PM.

Details

Summary

Sanitizers set nobuiltin attribute on certain library functions to
avoid a situation where such function is neither instrumented nor
intercepted.

At the moment the list of interesting functions is hardcoded. This
change replaces it with logic based on
TargetLibraryInfo::hasOptimizedCodegen and the presense of readnone
function attribute (sanitizers are generally interested in memory
behavior of library functions).

This is expected to be a no-op change: the new logic matches exactly
the same set of functions.

r276771 (currently reverted) added mempcpy() to the list, breaking
MSan tests. With this change, r276771 can be safely re-landed.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis updated this revision to Diff 65844.Jul 27 2016, 5:18 PM
eugenis retitled this revision from to [sanitizer] Simplify and future-proof maybeMarkSanitizerLibraryCallNoBuiltin()..
eugenis updated this object.
eugenis set the repository for this revision to rL LLVM.
eugenis added a subscriber: llvm-commits.

Hi Evgeniy,

Thank you for adding support for mempcpy to resolve the MSan fails caused by r276771.
Your change looks right to me.

memcpy() and memmov(), which are represented in the IR as intrinsics, would also, I think, be getting marked with Attribute::NoBuiltin for the purposes of MSan testing. They appear to be handled in a different way from the LibFunc functions.

Thanks
Sunita

Thanks
Sunita

Right, memcpy/memmove _intrinsics_ are handled specially in sanitizer instrumentation passes. Memcpy/memmove functions are not; and neither are they inlined in the codegen (at least I hope so, otherwise we have a problem). They are not mentioned in hasOptimizedCodeGen, too, so this change does not affect them.

Thank you Evgeniy, yes my comment was about the memcpy/memov intrinsics.
Sunita

vitalybuka accepted this revision.Jul 28 2016, 4:09 PM
vitalybuka added a reviewer: vitalybuka.
vitalybuka added a subscriber: vitalybuka.

lgtm

This revision is now accepted and ready to land.Jul 28 2016, 4:09 PM
eugenis closed this revision.Jul 28 2016, 4:53 PM

r277086