blob: 38aa8726d19cc12fffd90083494f36d3a2186cb2 [file] [log] [blame]
Krzysztof Parzyszekc9d4caa2016-03-24 20:20:07 +00001; RUN: llc -march=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 %0 = bitcast [1024 x i32]* %local to i8*
Matt Arsenaultf10061e2017-04-10 20:18:21 +00009 call void @llvm.lifetime.start.p0i8(i64 4096, i8* %0) #1
Krzysztof Parzyszekc9d4caa2016-03-24 20:20:07 +000010 %arraydecay = getelementptr inbounds [1024 x i32], [1024 x i32]* %local, i32 0, i32 0
11 call void @baz_1(i32* %arraydecay) #3
12 %arrayidx = getelementptr inbounds [1024 x i32], [1024 x i32]* %local, i32 0, i32 %n
13 %1 = load i32, i32* %arrayidx, align 4
Matt Arsenaultf10061e2017-04-10 20:18:21 +000014 call void @llvm.lifetime.end.p0i8(i64 4096, i8* %0) #1
Krzysztof Parzyszekc9d4caa2016-03-24 20:20:07 +000015 ret i32 %1
16}
17
18; CHECK-LABEL: foo_2
19; CHECK: __save_r16_through_r19_stkchk
20define i32 @foo_2(i32 %n, i32* %y) #0 {
21entry:
22 %local = alloca [2048 x i32], align 8
23 %0 = bitcast [2048 x i32]* %local to i8*
Matt Arsenaultf10061e2017-04-10 20:18:21 +000024 call void @llvm.lifetime.start.p0i8(i64 8192, i8* %0) #1
Krzysztof Parzyszekc9d4caa2016-03-24 20:20:07 +000025 %arraydecay = getelementptr inbounds [2048 x i32], [2048 x i32]* %local, i32 0, i32 0
26 call void @baz_2(i32* %y, i32* %arraydecay) #3
27 %1 = load i32, i32* %y, align 4
28 %add = add nsw i32 %n, %1
29 %arrayidx = getelementptr inbounds [2048 x i32], [2048 x i32]* %local, i32 0, i32 %add
30 %2 = load i32, i32* %arrayidx, align 4
Matt Arsenaultf10061e2017-04-10 20:18:21 +000031 call void @llvm.lifetime.end.p0i8(i64 8192, i8* %0) #1
Krzysztof Parzyszekc9d4caa2016-03-24 20:20:07 +000032 ret i32 %2
33}
34
35declare void @baz_1(i32*) #2
36declare void @baz_2(i32*, i32*) #2
Matt Arsenaultf10061e2017-04-10 20:18:21 +000037declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
38declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
Krzysztof Parzyszekc9d4caa2016-03-24 20:20:07 +000039
40attributes #0 = { nounwind optsize "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
41attributes #1 = { nounwind }
42attributes #2 = { optsize "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
43attributes #3 = { optsize }
44