112 lines · plain
1; Test handling of llvm.lifetime intrinsics with C++ exceptions.2; RUN: opt < %s -passes=asan -asan-use-after-scope -asan-use-after-return=never -S | FileCheck %s3 4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"5target triple = "x86_64-unknown-linux-gnu"6 7%struct.ABC = type { i32 }8 9$_ZN3ABCD2Ev = comdat any10$_ZTS3ABC = comdat any11$_ZTI3ABC = comdat any12 13@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr14@_ZTS3ABC = linkonce_odr constant [5 x i8] c"3ABC\00", comdat15@_ZTI3ABC = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 2), ptr @_ZTS3ABC }, comdat16 17define void @Throw() sanitize_address personality ptr @__gxx_personality_v0 {18; CHECK-LABEL: define void @Throw()19entry:20 %x = alloca %struct.ABC, align 421 22 ; Poison memory in prologue: F1F1F1F1F8F3F3F323 ; CHECK: store i64 -868082052615769615, ptr %{{[0-9]+}}24 25 call void @llvm.lifetime.start.p0(i64 4, ptr %x)26 ; CHECK: store i8 4, ptr %{{[0-9]+}}27 ; CHECK-NOT: @llvm.lifetime.start28 29 %exception = call ptr @__cxa_allocate_exception(i64 4)30 invoke void @__cxa_throw(ptr %exception, ptr @_ZTI3ABC, ptr @_ZN3ABCD2Ev) noreturn31 to label %unreachable unwind label %lpad32 ; CHECK: call void @__asan_handle_no_return33 ; CHECK-NEXT: @__cxa_throw34 35lpad:36 %0 = landingpad { ptr, i32 }37 cleanup38 call void @_ZN3ABCD2Ev(ptr nonnull %x)39 call void @llvm.lifetime.end.p0(i64 4, ptr %x)40 ; CHECK: store i8 -8, ptr %{{[0-9]+}}41 ; CHECK-NOT: @llvm.lifetime.end42 43 resume { ptr, i32 } %044 ; CHECK: store i64 0, ptr %{{[0-9]+}}45 ; CHECK-NEXT: resume46 47unreachable:48 unreachable49}50 51%rtti.TypeDescriptor9 = type { ptr, ptr, [10 x i8] }52%eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }53%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }54%eh.ThrowInfo = type { i32, i32, i32, i32 }55 56$"\01??1ABC@@QEAA@XZ" = comdat any57$"\01??_R0?AUABC@@@8" = comdat any58$"_CT??_R0?AUABC@@@84" = comdat any59$"_CTA1?AUABC@@" = comdat any60$"_TI1?AUABC@@" = comdat any61 62@"\01??_7type_info@@6B@" = external constant ptr63@"\01??_R0?AUABC@@@8" = linkonce_odr global %rtti.TypeDescriptor9 { ptr @"\01??_7type_info@@6B@", ptr null, [10 x i8] c".?AUABC@@\00" }, comdat64@__ImageBase = external constant i865@"_CT??_R0?AUABC@@@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??_R0?AUABC@@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat66@"_CTA1?AUABC@@" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"_CT??_R0?AUABC@@@84" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32)] }, section ".xdata", comdat67@"_TI1?AUABC@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"\01??1ABC@@QEAA@XZ" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"_CTA1?AUABC@@" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, section ".xdata", comdat68 69define void @ThrowWin() sanitize_address personality ptr @__CxxFrameHandler3 {70; CHECK-LABEL: define void @ThrowWin()71entry:72 %x = alloca %struct.ABC, align 473 %tmp = alloca %struct.ABC, align 474 75 ; Poison memory in prologue: F1F1F1F1F8F304F276 ; CHECK: store i64 -935355671561244175, ptr %{{[0-9]+}}77 78 call void @llvm.lifetime.start.p0(i64 4, ptr %x)79 ; CHECK: store i8 4, ptr %{{[0-9]+}}80 ; CHECK-NOT: @llvm.lifetime.start81 82 invoke void @_CxxThrowException(ptr %tmp, ptr nonnull @"_TI1?AUABC@@") noreturn83 to label %unreachable unwind label %ehcleanup84 ; CHECK: call void @__asan_handle_no_return85 ; CHECK-NEXT: @_CxxThrowException86 87ehcleanup:88 %0 = cleanuppad within none []89 call void @"\01??1ABC@@QEAA@XZ"(ptr nonnull %x) [ "funclet"(token %0) ]90 call void @llvm.lifetime.end.p0(i64 4, ptr %x)91 ; CHECK: store i8 -8, ptr %{{[0-9]+}}92 ; CHECK-NOT: @llvm.lifetime.end93 94 cleanupret from %0 unwind to caller95 ; CHECK: store i64 0, ptr %{{[0-9]+}}96 ; CHECK-NEXT: cleanupret97 98unreachable:99 unreachable100}101 102 103declare i32 @__gxx_personality_v0(...)104declare void @llvm.lifetime.start.p0(i64, ptr nocapture)105declare void @llvm.lifetime.end.p0(i64, ptr nocapture)106declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr107declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr108declare void @_ZN3ABCD2Ev(ptr %this) unnamed_addr109declare void @"\01??1ABC@@QEAA@XZ"(ptr %this)110declare void @_CxxThrowException(ptr, ptr)111declare i32 @__CxxFrameHandler3(...)112