1; Test stack pointer restore after setjmp() with the function-call safestack ABI.
2; RUN: opt -safe-stack -S -mtriple=arm-linux-androideabi < %s -o - | FileCheck %s
3
4@env = global [64 x i32] zeroinitializer, align 4
5
6define void @f(i32 %b) safestack {
7entry:
8; CHECK: %[[SPA:.*]] = call i8** @__safestack_pointer_address()
9; CHECK: %[[USDP:.*]] = alloca i8*
10; CHECK: %[[USP:.*]] = load i8*, i8** %[[SPA]]
11; CHECK: store i8* %[[USP]], i8** %[[USDP]]
12; CHECK: call i32 @setjmp
13
14  %call = call i32 @setjmp(i32* getelementptr inbounds ([64 x i32], [64 x i32]* @env, i32 0, i32 0)) returns_twice
15
16; CHECK: %[[USP2:.*]] = load i8*, i8** %[[USDP]]
17; CHECK: store i8* %[[USP2]], i8** %[[SPA]]
18
19  %tobool = icmp eq i32 %b, 0
20  br i1 %tobool, label %if.end, label %if.then
21
22if.then:
23  %0 = alloca [42 x i8], align 1
24  %.sub = getelementptr inbounds [42 x i8], [42 x i8]* %0, i32 0, i32 0
25  call void @_Z7CapturePv(i8* %.sub)
26  br label %if.end
27
28if.end:
29  ret void
30}
31
32declare i32 @setjmp(i32*) returns_twice
33
34declare void @_Z7CapturePv(i8*)
35