xref: /llvm-project/llvm/test/CodeGen/BPF/warn-stack.ll (revision c5037db4acd95790a0ca5061c8fa79c5c291607e)
1; RUN: not llc -mtriple=bpfel < %s 2>&1 >/dev/null | FileCheck %s
2
3;; CHECK-NOT: nowarn
4define void @nowarn() local_unnamed_addr #0 !dbg !6 {
5  %1 = alloca [504 x i8], align 1
6  call void @llvm.lifetime.start.p0(i64 504, ptr nonnull %1) #4, !dbg !15
7  tail call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !16), !dbg !17
8  call void @doit(ptr nonnull %1) #4, !dbg !18
9  call void @llvm.lifetime.end.p0(i64 504, ptr nonnull %1) #4, !dbg !19
10  ret void, !dbg !19
11}
12
13; Function Attrs: argmemonly nounwind
14declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1
15
16; Function Attrs: nounwind readnone
17declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
18
19declare void @doit(ptr) local_unnamed_addr #3
20
21; Function Attrs: argmemonly nounwind
22declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
23
24; CHECK: error: warn_stack.c
25; CHECK: BPF stack limit
26define void @warn() local_unnamed_addr #0 !dbg !20 {
27  %1 = alloca [512 x i8], align 1
28  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %1) #4, !dbg !26
29  tail call void @llvm.dbg.declare(metadata ptr %1, metadata !22, metadata !16), !dbg !27
30  call void @doit(ptr nonnull %1) #4, !dbg !28
31  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %1) #4, !dbg !29
32  ret void, !dbg !29
33}
34
35attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
36attributes #1 = { argmemonly nounwind }
37attributes #2 = { nounwind readnone }
38attributes #3 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
39attributes #4 = { nounwind }
40
41!llvm.dbg.cu = !{!0}
42!llvm.module.flags = !{!3, !4}
43!llvm.ident = !{!5}
44
45!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 (trunk 292141) (llvm/trunk 292156)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
46!1 = !DIFile(filename: "warn_stack.c", directory: "/w/llvm/bld")
47!2 = !{}
48!3 = !{i32 2, !"Dwarf Version", i32 4}
49!4 = !{i32 2, !"Debug Info Version", i32 3}
50!5 = !{!"clang version 5.0.0 (trunk 292141) (llvm/trunk 292156)"}
51!6 = distinct !DISubprogram(name: "nowarn", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !9)
52!7 = !DISubroutineType(types: !8)
53!8 = !{null}
54!9 = !{!10}
55!10 = !DILocalVariable(name: "buf", scope: !6, file: !1, line: 4, type: !11)
56!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 4088, elements: !13)
57!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
58!13 = !{!14}
59!14 = !DISubrange(count: 504)
60!15 = !DILocation(line: 4, column: 2, scope: !6)
61!16 = !DIExpression()
62!17 = !DILocation(line: 4, column: 7, scope: !6)
63!18 = !DILocation(line: 5, column: 2, scope: !6)
64!19 = !DILocation(line: 6, column: 1, scope: !6)
65!20 = distinct !DISubprogram(name: "warn", scope: !1, file: !1, line: 7, type: !7, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !21)
66!21 = !{!22}
67!22 = !DILocalVariable(name: "buf", scope: !20, file: !1, line: 9, type: !23)
68!23 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 4096, elements: !24)
69!24 = !{!25}
70!25 = !DISubrange(count: 512)
71!26 = !DILocation(line: 9, column: 2, scope: !20)
72!27 = !DILocation(line: 9, column: 7, scope: !20)
73!28 = !DILocation(line: 10, column: 2, scope: !20)
74!29 = !DILocation(line: 11, column: 1, scope: !20)
75