1 ; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
2 ; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
5 ; int foo(char a) { volatile short b = 0; return b; }
7 ; clang -target bpf -O2 -g -S -emit-llvm test.c
9 ; Function Attrs: nounwind
10 define dso_local i32 @foo(i8 signext) local_unnamed_addr #0 !dbg !7 {
11 %2 = alloca i16, align 2
12 call void @llvm.dbg.value(metadata i8 %0, metadata !13, metadata !DIExpression()), !dbg !17
13 %3 = bitcast i16* %2 to i8*, !dbg !18
14 call void @llvm.lifetime.start.p0i8(i64 2, i8* nonnull %3), !dbg !18
15 call void @llvm.dbg.declare(metadata i16* %2, metadata !14, metadata !DIExpression()), !dbg !19
16 store volatile i16 0, i16* %2, align 2, !dbg !19, !tbaa !20
17 %4 = load volatile i16, i16* %2, align 2, !dbg !24, !tbaa !20
18 %5 = sext i16 %4 to i32, !dbg !24
19 call void @llvm.lifetime.end.p0i8(i64 2, i8* nonnull %3), !dbg !25
23 ; CHECK: .section .BTF,"",@progbits
24 ; CHECK-NEXT: .short 60319 # 0xeb9f
27 ; CHECK-NEXT: .long 24
29 ; CHECK-NEXT: .long 64
30 ; CHECK-NEXT: .long 64
31 ; CHECK-NEXT: .long 59
32 ; CHECK-NEXT: .long 1 # BTF_KIND_INT(id = 1)
33 ; CHECK-NEXT: .long 16777216 # 0x1000000
35 ; CHECK-NEXT: .long 16777224 # 0x1000008
36 ; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 2)
37 ; CHECK-NEXT: .long 218103809 # 0xd000001
41 ; CHECK-NEXT: .long 8 # BTF_KIND_INT(id = 3)
42 ; CHECK-NEXT: .long 16777216 # 0x1000000
44 ; CHECK-NEXT: .long 16777248 # 0x1000020
45 ; CHECK-NEXT: .long 12 # BTF_KIND_FUNC(id = 4)
46 ; CHECK-NEXT: .long 201326592 # 0xc000000
48 ; CHECK-NEXT: .byte 0 # string offset=0
49 ; CHECK-NEXT: .ascii "char" # string offset=1
51 ; CHECK-NEXT: .byte 97 # string offset=6
53 ; CHECK-NEXT: .ascii "int" # string offset=8
55 ; CHECK-NEXT: .ascii "foo" # string offset=12
57 ; CHECK-NEXT: .ascii ".text" # string offset=16
59 ; CHECK-NEXT: .ascii "/home/yhs/work/tests/llvm/bug/test.c" # string offset=22
62 ; Function Attrs: nounwind readnone speculatable
63 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
65 ; Function Attrs: argmemonly nounwind
66 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
68 ; Function Attrs: argmemonly nounwind
69 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
71 ; Function Attrs: nounwind readnone speculatable
72 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
74 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" }
75 attributes #1 = { nounwind readnone speculatable }
76 attributes #2 = { argmemonly nounwind }
79 !llvm.module.flags = !{!3, !4, !5}
82 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.20181009 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
83 !1 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/llvm/bug")
85 !3 = !{i32 2, !"Dwarf Version", i32 4}
86 !4 = !{i32 2, !"Debug Info Version", i32 3}
87 !5 = !{i32 1, !"wchar_size", i32 4}
88 !6 = !{!"clang version 8.0.20181009 "}
89 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
90 !8 = !DISubroutineType(types: !9)
92 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
93 !11 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
95 !13 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !11)
96 !14 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 1, type: !15)
97 !15 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !16)
98 !16 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
99 !17 = !DILocation(line: 1, column: 14, scope: !7)
100 !18 = !DILocation(line: 1, column: 19, scope: !7)
101 !19 = !DILocation(line: 1, column: 34, scope: !7)
102 !20 = !{!21, !21, i64 0}
103 !21 = !{!"short", !22, i64 0}
104 !22 = !{!"omnipotent char", !23, i64 0}
105 !23 = !{!"Simple C/C++ TBAA"}
106 !24 = !DILocation(line: 1, column: 49, scope: !7)
107 !25 = !DILocation(line: 1, column: 52, scope: !7)
108 !26 = !DILocation(line: 1, column: 42, scope: !7)