xref: /llvm-project/llvm/test/CodeGen/Hexagon/runtime-stkchk.ll (revision a96f691985c8546e826012fdc3481c88f034a194)
1; RUN: llc -mtriple=hexagon -mcpu=hexagonv55 -enable-stackovf-sanitizer < %s | FileCheck %s
2
3; CHECK-LABEL: foo_1
4; CHECK: __runtime_stack_check
5define i32 @foo_1(i32 %n) #0 {
6entry:
7  %local = alloca [1024 x i32], align 8
8  call void @llvm.lifetime.start.p0(i64 4096, ptr %local) #1
9  call void @baz_1(ptr %local) #3
10  %arrayidx = getelementptr inbounds [1024 x i32], ptr %local, i32 0, i32 %n
11  %0 = load i32, ptr %arrayidx, align 4
12  call void @llvm.lifetime.end.p0(i64 4096, ptr %local) #1
13  ret i32 %0
14}
15
16; CHECK-LABEL: foo_2
17; CHECK: __save_r16_through_r19_stkchk
18define i32 @foo_2(i32 %n, ptr %y) #0 {
19entry:
20  %local = alloca [2048 x i32], align 8
21  call void @llvm.lifetime.start.p0(i64 8192, ptr %local) #1
22  call void @baz_2(ptr %y, ptr %local) #3
23  %0 = load i32, ptr %y, align 4
24  %add = add nsw i32 %n, %0
25  %arrayidx = getelementptr inbounds [2048 x i32], ptr %local, i32 0, i32 %add
26  %1 = load i32, ptr %arrayidx, align 4
27  call void @llvm.lifetime.end.p0(i64 8192, ptr %local) #1
28  ret i32 %1
29}
30
31declare void @baz_1(ptr) #2
32declare void @baz_2(ptr, ptr) #2
33declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1
34declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
35
36attributes #0 = { nounwind optsize "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
37attributes #1 = { nounwind }
38attributes #2 = { optsize "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
39attributes #3 = { optsize }
40
41