]> granicus.if.org Git - clang/commitdiff
[libFuzzer] Use OptForFuzzing attribute with -fsanitize=fuzzer.
authorMatt Morehouse <mascasa@google.com>
Fri, 23 Mar 2018 23:35:28 +0000 (23:35 +0000)
committerMatt Morehouse <mascasa@google.com>
Fri, 23 Mar 2018 23:35:28 +0000 (23:35 +0000)
Summary:
Disables certain CMP optimizations to improve fuzzing signal under -O1
and -O2.

Switches all fuzzer tests to -O2 except for a few leak tests where the
leak is optimized out under -O2.

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D44798

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328384 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenFunction.cpp

index c5de16bc6eb05d62aa46f01f3340cf67e8c669e8..3d7b90658763f6188ce74d47bfbecf22b25cf8d7 100644 (file)
@@ -862,6 +862,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,
   if (SanOpts.has(SanitizerKind::SafeStack))
     Fn->addFnAttr(llvm::Attribute::SafeStack);
 
+  // Apply fuzzing attribute to the function.
+  if (SanOpts.hasOneOf(SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink))
+    Fn->addFnAttr(llvm::Attribute::OptForFuzzing);
+
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
   // .cxx_destruct, __destroy_helper_block_ and all of their calees at run time.
   if (SanOpts.has(SanitizerKind::Thread)) {