llvm.org GIT mirror llvm / 1479c9b
[asan] instrument invoke insns with noreturn attribute (as well as call insns) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175617 91177308-0d34-0410-b5e6-96231b3b80d8 Kostya Serebryany 6 years ago
2 changed file(s) with 27 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
3434 #include "llvm/IR/Module.h"
3535 #include "llvm/IR/Type.h"
3636 #include "llvm/InstVisitor.h"
37 #include "llvm/Support/CallSite.h"
3738 #include "llvm/Support/CommandLine.h"
3839 #include "llvm/Support/DataTypes.h"
3940 #include "llvm/Support/Debug.h"
11291130 } else if (isa(BI) && ClMemIntrin) {
11301131 // ok, take it.
11311132 } else {
1132 if (CallInst *CI = dyn_cast(BI)) {
1133 CallSite CS(BI);
1134 if (CS) {
11331135 // A call inside BB.
11341136 TempsToInstrument.clear();
1135 if (CI->doesNotReturn()) {
1136 NoReturnCalls.push_back(CI);
1137 }
1137 if (CS.doesNotReturn())
1138 NoReturnCalls.push_back(CS.getInstruction());
11381139 }
11391140 continue;
11401141 }
0 ; RUN: opt < %s -asan -S | FileCheck %s
11 ; AddressSanitizer must insert __asan_handle_no_return
2 ; before every noreturn call.
2 ; before every noreturn call or invoke.
33
44 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
55 target triple = "x86_64-unknown-linux-gnu"
2525 ; CHECK-NEXT: unreachable
2626 unreachable
2727 }
28
29 declare i32 @__gxx_personality_v0(...)
30
31 define i64 @Invoke1(i8** %esc) nounwind uwtable ssp address_safety {
32 entry:
33 invoke void @MyNoReturnFunc(i32 1)
34 to label %invoke.cont unwind label %lpad
35
36 invoke.cont:
37 ret i64 0
38
39 lpad:
40 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
41 filter [0 x i8*] zeroinitializer
42 ret i64 1
43 }
44 ; CHECK: @Invoke1
45 ; CHECK: call void @__asan_handle_no_return
46 ; CHECK-NEXT: invoke void @MyNoReturnFunc
47 ; CHECK: ret i64 0
48 ; CHECK: ret i64 1