[llvm] r277086 - [sanitizer] Simplify and future-proof maybeMarkSanitizerLibraryCallNoBuiltin().
Evgeniy Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 28 16:45:15 PDT 2016
Author: eugenis
Date: Thu Jul 28 18:45:15 2016
New Revision: 277086
URL: http://llvm.org/viewvc/llvm-project?rev=277086&view=rev
Log:
[sanitizer] Simplify and future-proof maybeMarkSanitizerLibraryCallNoBuiltin().
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.
Modified:
llvm/trunk/lib/Transforms/Utils/Local.cpp
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=277086&r1=277085&r2=277086&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Thu Jul 28 18:45:15 2016
@@ -1954,23 +1954,12 @@ bool llvm::recognizeBSwapOrBitReverseIdi
// in ASan/MSan/TSan/DFSan, and thus make us miss some memory accesses,
// we mark affected calls as NoBuiltin, which will disable optimization
// in CodeGen.
-void llvm::maybeMarkSanitizerLibraryCallNoBuiltin(CallInst *CI,
- const TargetLibraryInfo *TLI) {
+void llvm::maybeMarkSanitizerLibraryCallNoBuiltin(
+ CallInst *CI, const TargetLibraryInfo *TLI) {
Function *F = CI->getCalledFunction();
LibFunc::Func Func;
- if (!F || F->hasLocalLinkage() || !F->hasName() ||
- !TLI->getLibFunc(F->getName(), Func))
- return;
- switch (Func) {
- default: break;
- case LibFunc::memcmp:
- case LibFunc::memchr:
- case LibFunc::strcpy:
- case LibFunc::stpcpy:
- case LibFunc::strcmp:
- case LibFunc::strlen:
- case LibFunc::strnlen:
- CI->addAttribute(AttributeSet::FunctionIndex, Attribute::NoBuiltin);
- break;
- }
+ if (F && !F->hasLocalLinkage() && F->hasName() &&
+ TLI->getLibFunc(F->getName(), Func) && TLI->hasOptimizedCodeGen(Func) &&
+ !F->doesNotAccessMemory())
+ CI->addAttribute(AttributeSet::FunctionIndex, Attribute::NoBuiltin);
}
More information about the llvm-commits
mailing list