2017-01-17 09:05:17 +08:00
|
|
|
; RUN: not llc -march=bpfel < %s 2>&1 >/dev/null | FileCheck %s
|
|
|
|
|
|
|
|
;; CHECK-NOT: nowarn
|
|
|
|
define void @nowarn() local_unnamed_addr #0 !dbg !6 {
|
|
|
|
%1 = alloca [504 x i8], align 1
|
|
|
|
%2 = getelementptr inbounds [504 x i8], [504 x i8]* %1, i64 0, i64 0, !dbg !15
|
2017-04-11 04:18:21 +08:00
|
|
|
call void @llvm.lifetime.start.p0i8(i64 504, i8* nonnull %2) #4, !dbg !15
|
2017-01-17 09:05:17 +08:00
|
|
|
tail call void @llvm.dbg.declare(metadata [504 x i8]* %1, metadata !10, metadata !16), !dbg !17
|
|
|
|
call void @doit(i8* nonnull %2) #4, !dbg !18
|
2017-04-11 04:18:21 +08:00
|
|
|
call void @llvm.lifetime.end.p0i8(i64 504, i8* nonnull %2) #4, !dbg !19
|
2017-01-17 09:05:17 +08:00
|
|
|
ret void, !dbg !19
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: argmemonly nounwind
|
2017-04-11 04:18:21 +08:00
|
|
|
declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
|
2017-01-17 09:05:17 +08:00
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
|
|
|
|
|
|
|
|
declare void @doit(i8*) local_unnamed_addr #3
|
|
|
|
|
|
|
|
; Function Attrs: argmemonly nounwind
|
2017-04-11 04:18:21 +08:00
|
|
|
declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
|
2017-01-17 09:05:17 +08:00
|
|
|
|
|
|
|
; CHECK: error: warn_stack.c
|
|
|
|
; CHECK: BPF stack limit
|
|
|
|
define void @warn() local_unnamed_addr #0 !dbg !20 {
|
|
|
|
%1 = alloca [512 x i8], align 1
|
|
|
|
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0, !dbg !26
|
2017-04-11 04:18:21 +08:00
|
|
|
call void @llvm.lifetime.start.p0i8(i64 512, i8* nonnull %2) #4, !dbg !26
|
2017-01-17 09:05:17 +08:00
|
|
|
tail call void @llvm.dbg.declare(metadata [512 x i8]* %1, metadata !22, metadata !16), !dbg !27
|
|
|
|
call void @doit(i8* nonnull %2) #4, !dbg !28
|
2017-04-11 04:18:21 +08:00
|
|
|
call void @llvm.lifetime.end.p0i8(i64 512, i8* nonnull %2) #4, !dbg !29
|
2017-01-17 09:05:17 +08:00
|
|
|
ret void, !dbg !29
|
|
|
|
}
|
|
|
|
|
2019-12-25 07:52:21 +08:00
|
|
|
attributes #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" }
|
2017-01-17 09:05:17 +08:00
|
|
|
attributes #1 = { argmemonly nounwind }
|
|
|
|
attributes #2 = { nounwind readnone }
|
2019-12-25 07:52:21 +08:00
|
|
|
attributes #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" }
|
2017-01-17 09:05:17 +08:00
|
|
|
attributes #4 = { nounwind }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!3, !4}
|
|
|
|
!llvm.ident = !{!5}
|
|
|
|
|
|
|
|
!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)
|
|
|
|
!1 = !DIFile(filename: "warn_stack.c", directory: "/w/llvm/bld")
|
|
|
|
!2 = !{}
|
|
|
|
!3 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!5 = !{!"clang version 5.0.0 (trunk 292141) (llvm/trunk 292156)"}
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!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)
|
2017-01-17 09:05:17 +08:00
|
|
|
!7 = !DISubroutineType(types: !8)
|
|
|
|
!8 = !{null}
|
|
|
|
!9 = !{!10}
|
|
|
|
!10 = !DILocalVariable(name: "buf", scope: !6, file: !1, line: 4, type: !11)
|
|
|
|
!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 4088, elements: !13)
|
|
|
|
!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
|
|
|
|
!13 = !{!14}
|
|
|
|
!14 = !DISubrange(count: 504)
|
|
|
|
!15 = !DILocation(line: 4, column: 2, scope: !6)
|
|
|
|
!16 = !DIExpression()
|
|
|
|
!17 = !DILocation(line: 4, column: 7, scope: !6)
|
|
|
|
!18 = !DILocation(line: 5, column: 2, scope: !6)
|
|
|
|
!19 = !DILocation(line: 6, column: 1, scope: !6)
|
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
|
|
|
!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)
|
2017-01-17 09:05:17 +08:00
|
|
|
!21 = !{!22}
|
|
|
|
!22 = !DILocalVariable(name: "buf", scope: !20, file: !1, line: 9, type: !23)
|
|
|
|
!23 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 4096, elements: !24)
|
|
|
|
!24 = !{!25}
|
|
|
|
!25 = !DISubrange(count: 512)
|
|
|
|
!26 = !DILocation(line: 9, column: 2, scope: !20)
|
|
|
|
!27 = !DILocation(line: 9, column: 7, scope: !20)
|
|
|
|
!28 = !DILocation(line: 10, column: 2, scope: !20)
|
|
|
|
!29 = !DILocation(line: 11, column: 1, scope: !20)
|