[llvm-commits] [llvm] r168861 - in /llvm/trunk: lib/Transforms/Instrumentation/AddressSanitizer.cpp test/Instrumentation/AddressSanitizer/instrument-no-return.ll
Kostya Serebryany
kcc at google.com
Thu Nov 29 00:57:20 PST 2012
Author: kcc
Date: Thu Nov 29 02:57:20 2012
New Revision: 168861
URL: http://llvm.org/viewvc/llvm-project?rev=168861&view=rev
Log:
[asan] when checking the noreturn attribute on the call, also check it on the callee
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/instrument-no-return.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=168861&r1=168860&r2=168861&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Thu Nov 29 02:57:20 2012
@@ -845,6 +845,14 @@
return false;
}
+// Check both the call and the callee for doesNotReturn().
+static bool isNoReturnCall(CallInst *CI) {
+ if (CI->doesNotReturn()) return true;
+ Function *F = CI->getCalledFunction();
+ if (F && F->doesNotReturn()) return true;
+ return false;
+}
+
bool AddressSanitizer::runOnFunction(Function &F) {
if (BL->isIn(F)) return false;
if (&F == AsanCtorFunction) return false;
@@ -885,7 +893,7 @@
if (CallInst *CI = dyn_cast<CallInst>(BI)) {
// A call inside BB.
TempsToInstrument.clear();
- if (CI->doesNotReturn()) {
+ if (isNoReturnCall(CI)) {
NoReturnCalls.push_back(CI);
}
}
Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/instrument-no-return.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/instrument-no-return.ll?rev=168861&r1=168860&r2=168861&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/instrument-no-return.ll (original)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/instrument-no-return.ll Thu Nov 29 02:57:20 2012
@@ -7,11 +7,22 @@
declare void @MyNoReturnFunc(i32) noreturn
-define i32 @_Z5ChildPv(i8* nocapture %arg) uwtable address_safety {
+define i32 @Call1(i8* nocapture %arg) uwtable address_safety {
entry:
- call void @MyNoReturnFunc(i32 1) noreturn
+ call void @MyNoReturnFunc(i32 1) noreturn ; The call insn has noreturn attr.
+; CHECK: @Call1
+; CHECK: call void @__asan_handle_no_return
+; CHECK-NEXT: call void @MyNoReturnFunc
+; CHECK-NEXT: unreachable
unreachable
}
+define i32 @Call2(i8* nocapture %arg) uwtable address_safety {
+entry:
+ call void @MyNoReturnFunc(i32 1) ; No noreturn attribure on the call.
+; CHECK: @Call2
; CHECK: call void @__asan_handle_no_return
; CHECK-NEXT: call void @MyNoReturnFunc
+; CHECK-NEXT: unreachable
+ unreachable
+}
More information about the llvm-commits
mailing list