1; Check that the __stack_chk_guard was placed in small data.
2; RUN: llc -march=hexagon -O2 -hexagon-small-data-threshold=4 < %s | FileCheck -check-prefix=GPREL %s
3; GPREL: memw(gp+#__stack_chk_guard)
4
5; For threshold less than 4 (size of address), the variable is not placed in small-data
6; RUN: llc -march=hexagon -O2 -hexagon-small-data-threshold=0 < %s | FileCheck -check-prefix=ABS %s
7; ABS: memw(##__stack_chk_guard)
8
9@g0 = private unnamed_addr constant [37 x i8] c"This string is longer than 16 bytes\0A\00", align 1
10@g1 = private unnamed_addr constant [15 x i8] c"\0AChar 20 = %c\0A\00", align 1
11
12; Function Attrs: noinline nounwind ssp
13define zeroext i8 @f0(i32 %a0) #0 {
14b0:
15  %v0 = alloca i32, align 4
16  %v1 = alloca [64 x i8], align 8
17  %v2 = alloca i8*, align 4
18  store i32 %a0, i32* %v0, align 4
19  store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @g0, i32 0, i32 0), i8** %v2, align 4
20  %v3 = getelementptr inbounds [64 x i8], [64 x i8]* %v1, i32 0, i32 0
21  %v4 = load i8*, i8** %v2, align 4
22  %v5 = call i8* @f1(i8* %v3, i8* %v4) #2
23  %v6 = load i32, i32* %v0, align 4
24  %v7 = getelementptr inbounds [64 x i8], [64 x i8]* %v1, i32 0, i32 %v6
25  %v8 = load i8, i8* %v7, align 1
26  ret i8 %v8
27}
28
29; Function Attrs: nounwind
30declare i8* @f1(i8*, i8*) #1
31
32; Function Attrs: noinline nounwind ssp
33define i32 @f2(i32 %a0, i8** %a1) #0 {
34b0:
35  %v0 = alloca i32, align 4
36  %v1 = alloca i32, align 4
37  %v2 = alloca i8**, align 4
38  store i32 0, i32* %v0, align 4
39  store i32 %a0, i32* %v1, align 4
40  store i8** %a1, i8*** %v2, align 4
41  %v3 = call zeroext i8 @f0(i32 20)
42  %v4 = zext i8 %v3 to i32
43  %v5 = call i32 (i8*, ...) @f3(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @g1, i32 0, i32 0), i32 %v4) #2
44  ret i32 0
45}
46
47; Function Attrs: nounwind
48declare i32 @f3(i8*, ...) #1
49
50attributes #0 = { noinline nounwind ssp "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" }
51attributes #1 = { nounwind "target-cpu"="hexagonv60" "target-features"="+hvx,+hvx-length64b" }
52attributes #2 = { nounwind }
53