1*9880d681SAndroid Build Coastguard Worker; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t } 5*9880d681SAndroid Build Coastguard Worker%struct.__sigset_t = type { [16 x i64] } 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Worker@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1 8*9880d681SAndroid Build Coastguard Worker@buf = internal global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 16 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker; setjmp/longjmp test. 11*9880d681SAndroid Build Coastguard Worker; Requires protector. 12*9880d681SAndroid Build Coastguard Workerdefine i32 @foo() nounwind uwtable safestack { 13*9880d681SAndroid Build Coastguard Workerentry: 14*9880d681SAndroid Build Coastguard Worker ; CHECK: %[[SP:.*]] = load i8*, i8** @__safestack_unsafe_stack_ptr 15*9880d681SAndroid Build Coastguard Worker ; CHECK: %[[STATICTOP:.*]] = getelementptr i8, i8* %[[SP]], i32 -16 16*9880d681SAndroid Build Coastguard Worker %retval = alloca i32, align 4 17*9880d681SAndroid Build Coastguard Worker %x = alloca i32, align 4 18*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %retval 19*9880d681SAndroid Build Coastguard Worker store i32 42, i32* %x, align 4 20*9880d681SAndroid Build Coastguard Worker %call = call i32 @_setjmp(%struct.__jmp_buf_tag* getelementptr inbounds ([1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* @buf, i32 0, i32 0)) returns_twice 21*9880d681SAndroid Build Coastguard Worker ; CHECK: setjmp 22*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: store i8* %[[STATICTOP]], i8** @__safestack_unsafe_stack_ptr 23*9880d681SAndroid Build Coastguard Worker %tobool = icmp ne i32 %call, 0 24*9880d681SAndroid Build Coastguard Worker br i1 %tobool, label %if.else, label %if.then 25*9880d681SAndroid Build Coastguard Workerif.then: ; preds = %entry 26*9880d681SAndroid Build Coastguard Worker call void @funcall(i32* %x) 27*9880d681SAndroid Build Coastguard Worker br label %if.end 28*9880d681SAndroid Build Coastguard Workerif.else: ; preds = %entry 29*9880d681SAndroid Build Coastguard Worker call i32 (...) @dummy() 30*9880d681SAndroid Build Coastguard Worker br label %if.end 31*9880d681SAndroid Build Coastguard Workerif.end: ; preds = %if.else, %if.then 32*9880d681SAndroid Build Coastguard Worker ret i32 0 33*9880d681SAndroid Build Coastguard Worker} 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Workerdeclare i32 @_setjmp(%struct.__jmp_buf_tag*) 36*9880d681SAndroid Build Coastguard Workerdeclare void @funcall(i32*) 37*9880d681SAndroid Build Coastguard Workerdeclare i32 @dummy(...) 38