blob: 6dcd4fefe934d21007e2955c75951503e64a3416 [file] [log] [blame]
Yonghong Song6db6b562019-03-16 15:36:31 +00001; 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
3
4; Source code:
5; static volatile char a __attribute__((section("maps")));
6; int foo() {
7; static volatile short b __attribute__((section("maps")));
8; return a + b;
9; }
10; Compilation flag:
11; clang -target bpf -O2 -g -S -emit-llvm test.c
12
13@foo.b = internal global i16 0, section "maps", align 2, !dbg !0
14@a = internal global i8 0, section "maps", align 1, !dbg !10
15
16; Function Attrs: norecurse nounwind
17define dso_local i32 @foo() local_unnamed_addr #0 !dbg !2 {
18 %1 = load volatile i8, i8* @a, align 1, !dbg !20, !tbaa !21
19 %2 = sext i8 %1 to i32, !dbg !20
20 %3 = load volatile i16, i16* @foo.b, align 2, !dbg !24, !tbaa !25
21 %4 = sext i16 %3 to i32, !dbg !24
22 %5 = add nsw i32 %4, %2, !dbg !27
23 ret i32 %5, !dbg !28
24}
25
26; CHECK: .section .BTF,"",@progbits
27; CHECK-NEXT: .short 60319 # 0xeb9f
28; CHECK-NEXT: .byte 1
29; CHECK-NEXT: .byte 0
30; CHECK-NEXT: .long 24
31; CHECK-NEXT: .long 0
32; CHECK-NEXT: .long 164
33; CHECK-NEXT: .long 164
34; CHECK-NEXT: .long 76
35; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1)
36; CHECK-NEXT: .long 218103808 # 0xd000000
37; CHECK-NEXT: .long 2
Yonghong Songd3d88d02019-07-09 15:28:41 +000038; CHECK-NEXT: .long 1 # BTF_KIND_INT(id = 2)
Yonghong Song6db6b562019-03-16 15:36:31 +000039; CHECK-NEXT: .long 16777216 # 0x1000000
40; CHECK-NEXT: .long 4
41; CHECK-NEXT: .long 16777248 # 0x1000020
Yonghong Songd3d88d02019-07-09 15:28:41 +000042; CHECK-NEXT: .long 5 # BTF_KIND_FUNC(id = 3)
Yonghong Song6db6b562019-03-16 15:36:31 +000043; CHECK-NEXT: .long 201326592 # 0xc000000
44; CHECK-NEXT: .long 1
45; CHECK-NEXT: .long 0 # BTF_KIND_VOLATILE(id = 4)
46; CHECK-NEXT: .long 150994944 # 0x9000000
47; CHECK-NEXT: .long 5
48; CHECK-NEXT: .long 52 # BTF_KIND_INT(id = 5)
49; CHECK-NEXT: .long 16777216 # 0x1000000
50; CHECK-NEXT: .long 2
51; CHECK-NEXT: .long 16777232 # 0x1000010
52; CHECK-NEXT: .long 58 # BTF_KIND_VAR(id = 6)
53; CHECK-NEXT: .long 234881024 # 0xe000000
Yonghong Songded9a442019-03-22 01:30:50 +000054; CHECK-NEXT: .long 4
Yonghong Song6db6b562019-03-16 15:36:31 +000055; CHECK-NEXT: .long 0
56; CHECK-NEXT: .long 0 # BTF_KIND_VOLATILE(id = 7)
57; CHECK-NEXT: .long 150994944 # 0x9000000
58; CHECK-NEXT: .long 8
59; CHECK-NEXT: .long 64 # BTF_KIND_INT(id = 8)
60; CHECK-NEXT: .long 16777216 # 0x1000000
61; CHECK-NEXT: .long 1
62; CHECK-NEXT: .long 16777224 # 0x1000008
63; CHECK-NEXT: .long 69 # BTF_KIND_VAR(id = 9)
64; CHECK-NEXT: .long 234881024 # 0xe000000
Yonghong Songded9a442019-03-22 01:30:50 +000065; CHECK-NEXT: .long 7
Yonghong Song6db6b562019-03-16 15:36:31 +000066; CHECK-NEXT: .long 0
67; CHECK-NEXT: .long 71 # BTF_KIND_DATASEC(id = 10)
68; CHECK-NEXT: .long 251658242 # 0xf000002
69; CHECK-NEXT: .long 0
70; CHECK-NEXT: .long 6
71; CHECK-NEXT: .long foo.b
72; CHECK-NEXT: .long 2
73; CHECK-NEXT: .long 9
74; CHECK-NEXT: .long a
75; CHECK-NEXT: .long 1
76; CHECK-NEXT: .byte 0 # string offset=0
Yonghong Songd3d88d02019-07-09 15:28:41 +000077; CHECK-NEXT: .ascii "int" # string offset=1
Yonghong Song6db6b562019-03-16 15:36:31 +000078; CHECK-NEXT: .byte 0
Yonghong Songd3d88d02019-07-09 15:28:41 +000079; CHECK-NEXT: .ascii "foo" # string offset=5
Yonghong Song6db6b562019-03-16 15:36:31 +000080; CHECK-NEXT: .byte 0
Yonghong Songd3d88d02019-07-09 15:28:41 +000081; CHECK-NEXT: .ascii ".text" # string offset=9
Yonghong Song6db6b562019-03-16 15:36:31 +000082; CHECK-NEXT: .byte 0
Yonghong Songd3d88d02019-07-09 15:28:41 +000083; CHECK-NEXT: .ascii "/home/yhs/work/tests/llvm/bug/test.c" # string offset=15
Yonghong Song6db6b562019-03-16 15:36:31 +000084; CHECK-NEXT: .byte 0
85; CHECK-NEXT: .ascii "short" # string offset=52
86; CHECK-NEXT: .byte 0
87; CHECK-NEXT: .ascii "foo.b" # string offset=58
88; CHECK-NEXT: .byte 0
89; CHECK-NEXT: .ascii "char" # string offset=64
90; CHECK-NEXT: .byte 0
91; CHECK-NEXT: .byte 97 # string offset=69
92; CHECK-NEXT: .byte 0
93; CHECK-NEXT: .ascii "maps" # string offset=71
94; CHECK-NEXT: .byte 0
95
96attributes #0 = { norecurse 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" }
97
98!llvm.dbg.cu = !{!7}
99!llvm.module.flags = !{!16, !17, !18}
100!llvm.ident = !{!19}
101
102!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
103!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 3, type: !14, isLocal: true, isDefinition: true)
104!2 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 2, type: !4, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !7, retainedNodes: !8)
105!3 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/llvm/bug")
106!4 = !DISubroutineType(types: !5)
107!5 = !{!6}
108!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
109!7 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 8.0.20181009 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !8, globals: !9, nameTableKind: None)
110!8 = !{}
111!9 = !{!0, !10}
112!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
113!11 = distinct !DIGlobalVariable(name: "a", scope: !7, file: !3, line: 1, type: !12, isLocal: true, isDefinition: true)
114!12 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !13)
115!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
116!14 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !15)
117!15 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
118!16 = !{i32 2, !"Dwarf Version", i32 4}
119!17 = !{i32 2, !"Debug Info Version", i32 3}
120!18 = !{i32 1, !"wchar_size", i32 4}
121!19 = !{!"clang version 8.0.20181009 "}
122!20 = !DILocation(line: 4, column: 10, scope: !2)
123!21 = !{!22, !22, i64 0}
124!22 = !{!"omnipotent char", !23, i64 0}
125!23 = !{!"Simple C/C++ TBAA"}
126!24 = !DILocation(line: 4, column: 14, scope: !2)
127!25 = !{!26, !26, i64 0}
128!26 = !{!"short", !22, i64 0}
129!27 = !DILocation(line: 4, column: 12, scope: !2)
130!28 = !DILocation(line: 4, column: 3, scope: !2)