diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-07-28 23:45:15 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2016-07-28 23:45:15 +0000 |
commit | d240a889ad7d9be18a83f56cc723f77f74e2f8de (patch) | |
tree | 68ce5adc95b8d58642e40132d086ad9ff4958440 /llvm | |
parent | c6af5ead8696f066fd5ec2978b9fc071ddf88a42 (diff) | |
download | bcm5719-llvm-d240a889ad7d9be18a83f56cc723f77f74e2f8de.tar.gz bcm5719-llvm-d240a889ad7d9be18a83f56cc723f77f74e2f8de.zip |
[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.
llvm-svn: 277086
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 40432680e38..3148bae292e 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1954,23 +1954,12 @@ bool llvm::recognizeBSwapOrBitReverseIdiom( // 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); } |