xref: /llvm-project/llvm/test/Transforms/SafeStack/X86/invoke.ll (revision 3bd517205799a152689434ceddf9493765f1e883)
1; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
2; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
3; RUN: opt -passes=safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
4; RUN: opt -passes=safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
5
6@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
7
8; Addr-of a variable passed into an invoke instruction.
9;  safestack attribute
10; Requires protector and stack restore after landing pad.
11define i32 @foo() uwtable safestack personality ptr @__gxx_personality_v0 {
12entry:
13  ; CHECK: %[[SP:.*]] = load ptr, ptr @__safestack_unsafe_stack_ptr
14  ; CHECK: %[[STATICTOP:.*]] = getelementptr i8, ptr %[[SP]], i32 -16
15  %a = alloca i32, align 4
16  %exn.slot = alloca ptr
17  %ehselector.slot = alloca i32
18  store i32 0, ptr %a, align 4
19  invoke void @_Z3exceptPi(ptr %a)
20          to label %invoke.cont unwind label %lpad
21
22invoke.cont:
23  ret i32 0
24
25lpad:
26  ; CHECK: landingpad
27  ; CHECK-NEXT: catch
28  %0 = landingpad { ptr, i32 }
29          catch ptr null
30  ; CHECK-NEXT: store ptr %[[STATICTOP]], ptr @__safestack_unsafe_stack_ptr
31  ret i32 0
32}
33
34declare void @_Z3exceptPi(ptr)
35declare i32 @__gxx_personality_v0(...)
36