r352948 - [ASan] Do not instrument other runtime functions with `__asan_handle_no_return`

Julian Lettner via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 1 18:05:16 PST 2019


Author: yln
Date: Fri Feb  1 18:05:16 2019
New Revision: 352948

URL: http://llvm.org/viewvc/llvm-project?rev=352948&view=rev
Log:
[ASan] Do not instrument other runtime functions with `__asan_handle_no_return`

Summary:
Currently, ASan inserts a call to `__asan_handle_no_return` before every
`noreturn` function call/invoke. This is unnecessary for calls to other
runtime funtions. This patch changes ASan to skip instrumentation for
functions calls marked with `!nosanitize` metadata.

Reviewers: TODO

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

Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=352948&r1=352947&r2=352948&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Feb  1 18:05:16 2019
@@ -4394,8 +4394,8 @@ RValue CodeGenFunction::EmitCall(const C
 
     // Strip away the noreturn attribute to better diagnose unreachable UB.
     if (SanOpts.has(SanitizerKind::Unreachable)) {
-      // Also remove from function since CI->hasFnAttr(..) also checks attributes
-      // of the called function.
+      // Also remove from function since CallBase::hasFnAttr additionally checks
+      // attributes of the called function.
       if (auto *F = CI->getCalledFunction())
         F->removeFnAttr(llvm::Attribute::NoReturn);
       CI->removeAttribute(llvm::AttributeList::FunctionIndex,

Modified: cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c?rev=352948&r1=352947&r2=352948&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c (original)
+++ cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c Fri Feb  1 18:05:16 2019
@@ -9,8 +9,7 @@ void calls_noreturn() {
   my_longjmp();
   // CHECK:      @__asan_handle_no_return{{.*}} !nosanitize
   // CHECK-NEXT: @my_longjmp(){{[^#]*}}
-  // CHECK:      @__asan_handle_no_return()
-  // CHECK-NEXT: @__ubsan_handle_builtin_unreachable{{.*}} !nosanitize
+  // CHECK:      @__ubsan_handle_builtin_unreachable{{.*}} !nosanitize
   // CHECK-NEXT: unreachable
 }
 




More information about the cfe-commits mailing list