From e3f5cbd9c006382b7084d877b8f022bea6093293 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 6 Apr 2023 10:53:46 +0200 Subject: [PATCH] [FunctionAttrs] Add more nounwind tests (NFC) Test variations where catch/filter catch all exceptions. --- llvm/test/Transforms/FunctionAttrs/nounwind.ll | 85 +++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/llvm/test/Transforms/FunctionAttrs/nounwind.ll b/llvm/test/Transforms/FunctionAttrs/nounwind.ll index 9adf5be..4d52e61 100644 --- a/llvm/test/Transforms/FunctionAttrs/nounwind.ll +++ b/llvm/test/Transforms/FunctionAttrs/nounwind.ll @@ -129,9 +129,9 @@ declare void @do_throw() declare void @abort() nounwind @catch_ty = external global ptr -define void @catch_landingpad() personality ptr @__gxx_personality_v0 { +define void @catch_specific_landingpad() personality ptr @__gxx_personality_v0 { ; CHECK: Function Attrs: noreturn nounwind -; CHECK-LABEL: define {{[^@]+}}@catch_landingpad +; CHECK-LABEL: define {{[^@]+}}@catch_specific_landingpad ; CHECK-SAME: () #[[ATTR3:[0-9]+]] personality ptr @__gxx_personality_v0 { ; CHECK-NEXT: invoke void @do_throw() ; CHECK-NEXT: to label [[UNREACHABLE:%.*]] unwind label [[LPAD:%.*]] @@ -156,6 +156,87 @@ unreachable: unreachable } +define void @catch_all_landingpad() personality ptr @__gxx_personality_v0 { +; CHECK: Function Attrs: noreturn nounwind +; CHECK-LABEL: define {{[^@]+}}@catch_all_landingpad +; CHECK-SAME: () #[[ATTR3]] personality ptr @__gxx_personality_v0 { +; CHECK-NEXT: invoke void @do_throw() +; CHECK-NEXT: to label [[UNREACHABLE:%.*]] unwind label [[LPAD:%.*]] +; CHECK: lpad: +; CHECK-NEXT: [[LP:%.*]] = landingpad { ptr, i32 } +; CHECK-NEXT: catch ptr null +; CHECK-NEXT: call void @abort() +; CHECK-NEXT: unreachable +; CHECK: unreachable: +; CHECK-NEXT: unreachable +; + invoke void @do_throw() + to label %unreachable unwind label %lpad + +lpad: + %lp = landingpad { ptr, i32 } + catch ptr null + call void @abort() + unreachable + +unreachable: + unreachable +} + +define void @filter_specific_landingpad() personality ptr @__gxx_personality_v0 { +; CHECK: Function Attrs: noreturn nounwind +; CHECK-LABEL: define {{[^@]+}}@filter_specific_landingpad +; CHECK-SAME: () #[[ATTR3]] personality ptr @__gxx_personality_v0 { +; CHECK-NEXT: invoke void @do_throw() +; CHECK-NEXT: to label [[UNREACHABLE:%.*]] unwind label [[LPAD:%.*]] +; CHECK: lpad: +; CHECK-NEXT: [[LP:%.*]] = landingpad { ptr, i32 } +; CHECK-NEXT: filter [1 x ptr] [ptr @catch_ty] +; CHECK-NEXT: call void @abort() +; CHECK-NEXT: unreachable +; CHECK: unreachable: +; CHECK-NEXT: unreachable +; + invoke void @do_throw() + to label %unreachable unwind label %lpad + +lpad: + %lp = landingpad { ptr, i32 } + filter [1 x ptr] [ptr @catch_ty] + call void @abort() + unreachable + +unreachable: + unreachable +} + +define void @filter_none_landingpad() personality ptr @__gxx_personality_v0 { +; CHECK: Function Attrs: noreturn nounwind +; CHECK-LABEL: define {{[^@]+}}@filter_none_landingpad +; CHECK-SAME: () #[[ATTR3]] personality ptr @__gxx_personality_v0 { +; CHECK-NEXT: invoke void @do_throw() +; CHECK-NEXT: to label [[UNREACHABLE:%.*]] unwind label [[LPAD:%.*]] +; CHECK: lpad: +; CHECK-NEXT: [[LP:%.*]] = landingpad { ptr, i32 } +; CHECK-NEXT: filter [0 x ptr] zeroinitializer +; CHECK-NEXT: call void @abort() +; CHECK-NEXT: unreachable +; CHECK: unreachable: +; CHECK-NEXT: unreachable +; + invoke void @do_throw() + to label %unreachable unwind label %lpad + +lpad: + %lp = landingpad { ptr, i32 } + filter [0 x ptr] zeroinitializer + call void @abort() + unreachable + +unreachable: + unreachable +} + define void @cleanup_landingpad() personality ptr @__gxx_personality_v0 { ; CHECK: Function Attrs: noreturn nounwind ; CHECK-LABEL: define {{[^@]+}}@cleanup_landingpad -- 2.7.4