blob: 7b1940d3ed66b83f3bfd7589481485100bc3deea [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 const char __attribute__((section("maps"))) a;
6; int foo() {
7; static volatile const short b __attribute__((section("maps"))) = 3;
8; return a + b;
9; }
10; Compilation flag:
11; clang -target bpf -O2 -g -S -emit-llvm test.c
12
13@foo.b = internal constant i16 3, section "maps", align 2, !dbg !0
14@a = internal constant 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 !22, !tbaa !23
19 %2 = sext i8 %1 to i32, !dbg !22
20 %3 = load volatile i16, i16* @foo.b, align 2, !dbg !26, !tbaa !27
21 %4 = sext i16 %3 to i32, !dbg !26
22 %5 = add nsw i32 %4, %2, !dbg !29
23 ret i32 %5, !dbg !30
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 188
33; CHECK-NEXT: .long 188
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_CONST(id = 4)
46; CHECK-NEXT: .long 167772160 # 0xa000000
47; CHECK-NEXT: .long 5
48; CHECK-NEXT: .long 0 # BTF_KIND_VOLATILE(id = 5)
49; CHECK-NEXT: .long 150994944 # 0x9000000
50; CHECK-NEXT: .long 6
51; CHECK-NEXT: .long 52 # BTF_KIND_INT(id = 6)
52; CHECK-NEXT: .long 16777216 # 0x1000000
53; CHECK-NEXT: .long 2
54; CHECK-NEXT: .long 16777232 # 0x1000010
55; CHECK-NEXT: .long 58 # BTF_KIND_VAR(id = 7)
56; CHECK-NEXT: .long 234881024 # 0xe000000
Yonghong Songded9a442019-03-22 01:30:50 +000057; CHECK-NEXT: .long 4
Yonghong Song6db6b562019-03-16 15:36:31 +000058; CHECK-NEXT: .long 0
59; CHECK-NEXT: .long 0 # BTF_KIND_CONST(id = 8)
60; CHECK-NEXT: .long 167772160 # 0xa000000
61; CHECK-NEXT: .long 9
62; CHECK-NEXT: .long 0 # BTF_KIND_VOLATILE(id = 9)
63; CHECK-NEXT: .long 150994944 # 0x9000000
64; CHECK-NEXT: .long 10
65; CHECK-NEXT: .long 64 # BTF_KIND_INT(id = 10)
66; CHECK-NEXT: .long 16777216 # 0x1000000
67; CHECK-NEXT: .long 1
68; CHECK-NEXT: .long 16777224 # 0x1000008
69; CHECK-NEXT: .long 69 # BTF_KIND_VAR(id = 11)
70; CHECK-NEXT: .long 234881024 # 0xe000000
Yonghong Songded9a442019-03-22 01:30:50 +000071; CHECK-NEXT: .long 8
Yonghong Song6db6b562019-03-16 15:36:31 +000072; CHECK-NEXT: .long 0
73; CHECK-NEXT: .long 71 # BTF_KIND_DATASEC(id = 12)
74; CHECK-NEXT: .long 251658242 # 0xf000002
75; CHECK-NEXT: .long 0
76; CHECK-NEXT: .long 7
77; CHECK-NEXT: .long foo.b
78; CHECK-NEXT: .long 2
79; CHECK-NEXT: .long 11
80; CHECK-NEXT: .long a
81; CHECK-NEXT: .long 1
82; CHECK-NEXT: .byte 0 # string offset=0
Yonghong Songd3d88d02019-07-09 15:28:41 +000083; CHECK-NEXT: .ascii "int" # string offset=1
Yonghong Song6db6b562019-03-16 15:36:31 +000084; CHECK-NEXT: .byte 0
Yonghong Songd3d88d02019-07-09 15:28:41 +000085; CHECK-NEXT: .ascii "foo" # string offset=5
Yonghong Song6db6b562019-03-16 15:36:31 +000086; CHECK-NEXT: .byte 0
Yonghong Songd3d88d02019-07-09 15:28:41 +000087; CHECK-NEXT: .ascii ".text" # string offset=9
Yonghong Song6db6b562019-03-16 15:36:31 +000088; CHECK-NEXT: .byte 0
Yonghong Songd3d88d02019-07-09 15:28:41 +000089; CHECK-NEXT: .ascii "/home/yhs/work/tests/llvm/bug/test.c" # string offset=15
Yonghong Song6db6b562019-03-16 15:36:31 +000090; CHECK-NEXT: .byte 0
91; CHECK-NEXT: .ascii "short" # string offset=52
92; CHECK-NEXT: .byte 0
93; CHECK-NEXT: .ascii "foo.b" # string offset=58
94; CHECK-NEXT: .byte 0
95; CHECK-NEXT: .ascii "char" # string offset=64
96; CHECK-NEXT: .byte 0
97; CHECK-NEXT: .byte 97 # string offset=69
98; CHECK-NEXT: .byte 0
99; CHECK-NEXT: .ascii "maps" # string offset=71
100; CHECK-NEXT: .byte 0
101
Fangrui Song502a77f2019-12-24 15:52:21 -0800102attributes #0 = { norecurse 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" }
Yonghong Song6db6b562019-03-16 15:36:31 +0000103
104!llvm.dbg.cu = !{!7}
105!llvm.module.flags = !{!18, !19, !20}
106!llvm.ident = !{!21}
107
108!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
109!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 3, type: !15, isLocal: true, isDefinition: true)
110!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)
111!3 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/llvm/bug")
112!4 = !DISubroutineType(types: !5)
113!5 = !{!6}
114!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
115!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)
116!8 = !{}
117!9 = !{!0, !10}
118!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
119!11 = distinct !DIGlobalVariable(name: "a", scope: !7, file: !3, line: 1, type: !12, isLocal: true, isDefinition: true)
120!12 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !13)
121!13 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !14)
122!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
123!15 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !16)
124!16 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !17)
125!17 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
126!18 = !{i32 2, !"Dwarf Version", i32 4}
127!19 = !{i32 2, !"Debug Info Version", i32 3}
128!20 = !{i32 1, !"wchar_size", i32 4}
129!21 = !{!"clang version 8.0.20181009 "}
130!22 = !DILocation(line: 4, column: 10, scope: !2)
131!23 = !{!24, !24, i64 0}
132!24 = !{!"omnipotent char", !25, i64 0}
133!25 = !{!"Simple C/C++ TBAA"}
134!26 = !DILocation(line: 4, column: 14, scope: !2)
135!27 = !{!28, !28, i64 0}
136!28 = !{!"short", !24, i64 0}
137!29 = !DILocation(line: 4, column: 12, scope: !2)
138!30 = !DILocation(line: 4, column: 3, scope: !2)