Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 1479c9b

Browse files
committed
[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
1 parent af3a542 commit 1479c9b

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "llvm/IR/Module.h"
3636
#include "llvm/IR/Type.h"
3737
#include "llvm/InstVisitor.h"
38+
#include "llvm/Support/CallSite.h"
3839
#include "llvm/Support/CommandLine.h"
3940
#include "llvm/Support/DataTypes.h"
4041
#include "llvm/Support/Debug.h"
@@ -1130,12 +1131,12 @@ bool AddressSanitizer::runOnFunction(Function &F) {
11301131
} else if (isa<MemIntrinsic>(BI) && ClMemIntrin) {
11311132
// ok, take it.
11321133
} else {
1133-
if (CallInst *CI = dyn_cast<CallInst>(BI)) {
1134+
CallSite CS(BI);
1135+
if (CS) {
11341136
// A call inside BB.
11351137
TempsToInstrument.clear();
1136-
if (CI->doesNotReturn()) {
1137-
NoReturnCalls.push_back(CI);
1138-
}
1138+
if (CS.doesNotReturn())
1139+
NoReturnCalls.push_back(CS.getInstruction());
11391140
}
11401141
continue;
11411142
}

test/Instrumentation/AddressSanitizer/instrument-no-return.ll

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: opt < %s -asan -S | FileCheck %s
22
; AddressSanitizer must insert __asan_handle_no_return
3-
; before every noreturn call.
3+
; before every noreturn call or invoke.
44

55
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"
66
target triple = "x86_64-unknown-linux-gnu"
@@ -26,3 +26,24 @@ entry:
2626
; CHECK-NEXT: unreachable
2727
unreachable
2828
}
29+
30+
declare i32 @__gxx_personality_v0(...)
31+
32+
define i64 @Invoke1(i8** %esc) nounwind uwtable ssp address_safety {
33+
entry:
34+
invoke void @MyNoReturnFunc(i32 1)
35+
to label %invoke.cont unwind label %lpad
36+
37+
invoke.cont:
38+
ret i64 0
39+
40+
lpad:
41+
%0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
42+
filter [0 x i8*] zeroinitializer
43+
ret i64 1
44+
}
45+
; CHECK: @Invoke1
46+
; CHECK: call void @__asan_handle_no_return
47+
; CHECK-NEXT: invoke void @MyNoReturnFunc
48+
; CHECK: ret i64 0
49+
; CHECK: ret i64 1

0 commit comments

Comments
 (0)