• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fms-extensions -DDECLARE_SETJMP -triple i686-windows-msvc   -emit-llvm %s -o - | FileCheck --check-prefix=I386 %s
2 // RUN: %clang_cc1 -fms-extensions -DDECLARE_SETJMP -triple x86_64-windows-msvc -emit-llvm %s -o - | FileCheck --check-prefix=X64 %s
3 // RUN: %clang_cc1 -fms-extensions -DDECLARE_SETJMP -triple aarch64-windows-msvc -emit-llvm %s -o - | FileCheck --check-prefix=AARCH64 %s
4 // RUN: %clang_cc1 -fms-extensions -triple i686-windows-msvc   -emit-llvm %s -o - | FileCheck --check-prefix=I386 %s
5 // RUN: %clang_cc1 -fms-extensions -triple x86_64-windows-msvc -emit-llvm %s -o - | FileCheck --check-prefix=X64 %s
6 // RUN: %clang_cc1 -fms-extensions -triple aarch64-windows-msvc -emit-llvm %s -o - | FileCheck --check-prefix=AARCH64 %s
7 typedef char jmp_buf[1];
8 
9 #ifdef DECLARE_SETJMP
10 int _setjmp(jmp_buf env);
11 int _setjmpex(jmp_buf env);
12 #endif
13 
14 jmp_buf jb;
15 
test_setjmp()16 int test_setjmp() {
17   return _setjmp(jb);
18   // I386-LABEL: define dso_local i32 @test_setjmp
19   // I386:       %[[call:.*]] = call i32 (i8*, i32, ...) @_setjmp3(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i32 0)
20   // I386-NEXT:  ret i32 %[[call]]
21 
22   // X64-LABEL: define dso_local i32 @test_setjmp
23   // X64:       %[[addr:.*]] = call i8* @llvm.frameaddress.p0i8(i32 0)
24   // X64:       %[[call:.*]] = call i32 @_setjmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i64 0, i64 0), i8* %[[addr]])
25   // X64-NEXT:  ret i32 %[[call]]
26 
27   // AARCH64-LABEL: define dso_local i32 @test_setjmp
28   // AARCH64:       %[[addr:.*]] = call i8* @llvm.sponentry.p0i8()
29   // AARCH64:       %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i64 0, i64 0), i8* %[[addr]])
30   // AARCH64-NEXT:  ret i32 %[[call]]
31 }
32 
test_setjmpex()33 int test_setjmpex() {
34   return _setjmpex(jb);
35   // X64-LABEL: define dso_local i32 @test_setjmpex
36   // X64:       %[[addr:.*]] = call i8* @llvm.frameaddress.p0i8(i32 0)
37   // X64:       %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i64 0, i64 0), i8* %[[addr]])
38   // X64-NEXT:  ret i32 %[[call]]
39 
40   // AARCH64-LABEL: define dso_local i32 @test_setjmpex
41   // AARCH64:       %[[addr:.*]] = call i8* @llvm.sponentry.p0i8()
42   // AARCH64:       %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @jb, i64 0, i64 0), i8* %[[addr]])
43   // AARCH64-NEXT:  ret i32 %[[call]]
44 }
45