1 ; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
3 declare i8* @llvm.frameallocate(i32)
4 declare i8* @llvm.frameaddress(i32)
5 declare i8* @llvm.framerecover(i8*, i8*)
6 declare i32 @printf(i8*, ...)
8 @str = internal constant [10 x i8] c"asdf: %d\0A\00"
10 define void @print_framealloc_from_fp(i8* %fp) {
11 %alloc = call i8* @llvm.framerecover(i8* bitcast (void(i32*, i32*)* @alloc_func to i8*), i8* %fp)
12 %alloc_i32 = bitcast i8* %alloc to i32*
13 %r = load i32, i32* %alloc_i32
14 call i32 (i8*, ...)* @printf(i8* getelementptr ([10 x i8]* @str, i32 0, i32 0), i32 %r)
18 ; CHECK-LABEL: print_framealloc_from_fp:
19 ; CHECK: movabsq $.Lframeallocation_alloc_func, %[[offs:[a-z]+]]
20 ; CHECK: movl (%rcx,%[[offs]]), %edx
21 ; CHECK: leaq {{.*}}(%rip), %rcx
25 define void @alloc_func(i32* %s, i32* %d) {
26 %alloc = call i8* @llvm.frameallocate(i32 16)
27 %alloc_i32 = bitcast i8* %alloc to i32*
28 store i32 42, i32* %alloc_i32
29 %fp = call i8* @llvm.frameaddress(i32 0)
30 call void @print_framealloc_from_fp(i8* %fp)
34 ; CHECK-LABEL: alloc_func:
35 ; CHECK: subq $48, %rsp
36 ; CHECK: .seh_stackalloc 48
37 ; CHECK: leaq 48(%rsp), %rbp
38 ; CHECK: .seh_setframe 5, 48
39 ; CHECK: .Lframeallocation_alloc_func = -[[offs:[0-9]+]]
40 ; CHECK: movl $42, -[[offs]](%rbp)
41 ; CHECK: leaq -48(%rbp), %rcx
42 ; CHECK: callq print_framealloc_from_fp