• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3;
4; Source code:
5;   typedef struct t1 { int f1; } __t1;
6;   extern __t1 global __attribute__((weak));
7;   int test() { return global.f1; }
8; Compilation flag:
9;   clang -target bpf -O2 -g -S -emit-llvm test.c
10
11%struct.t1 = type { i32 }
12
13@global = extern_weak dso_local local_unnamed_addr global %struct.t1, align 4, !dbg !0
14; Function Attrs: norecurse nounwind readonly
15define dso_local i32 @test() local_unnamed_addr #0 !dbg !15 {
16entry:
17  %0 = load i32, i32* getelementptr (%struct.t1, %struct.t1* @global, i64 0, i32 0), align 4, !dbg !18, !tbaa !19
18  ret i32 %0, !dbg !24
19}
20
21; CHECK:             .section        .BTF,"",@progbits
22; CHECK-NEXT:        .short  60319                   # 0xeb9f
23; CHECK-NEXT:        .byte   1
24; CHECK-NEXT:        .byte   0
25; CHECK-NEXT:        .long   24
26; CHECK-NEXT:        .long   0
27; CHECK-NEXT:        .long   116
28; CHECK-NEXT:        .long   116
29; CHECK-NEXT:        .long   81
30; CHECK-NEXT:        .long   0                       # BTF_KIND_FUNC_PROTO(id = 1)
31; CHECK-NEXT:        .long   218103808               # 0xd000000
32; CHECK-NEXT:        .long   2
33; CHECK-NEXT:        .long   1                       # BTF_KIND_INT(id = 2)
34; CHECK-NEXT:        .long   16777216                # 0x1000000
35; CHECK-NEXT:        .long   4
36; CHECK-NEXT:        .long   16777248                # 0x1000020
37; CHECK-NEXT:        .long   5                       # BTF_KIND_FUNC(id = 3)
38; CHECK-NEXT:        .long   201326593               # 0xc000001
39; CHECK-NEXT:        .long   1
40; CHECK-NEXT:        .long   55                      # BTF_KIND_TYPEDEF(id = 4)
41; CHECK-NEXT:        .long   134217728               # 0x8000000
42; CHECK-NEXT:        .long   5
43; CHECK-NEXT:        .long   60                      # BTF_KIND_STRUCT(id = 5)
44; CHECK-NEXT:        .long   67108865                # 0x4000001
45; CHECK-NEXT:        .long   4
46; CHECK-NEXT:        .long   63
47; CHECK-NEXT:        .long   2
48; CHECK-NEXT:        .long   0                       # 0x0
49; CHECK-NEXT:        .long   66                      # BTF_KIND_VAR(id = 6)
50; CHECK-NEXT:        .long   234881024               # 0xe000000
51; CHECK-NEXT:        .long   4
52; CHECK-NEXT:        .long   2
53; CHECK-NEXT:        .long   73                      # BTF_KIND_DATASEC(id = 7)
54; CHECK-NEXT:        .long   251658241               # 0xf000001
55; CHECK-NEXT:        .long   0
56; CHECK-NEXT:        .long   6
57; CHECK-NEXT:        .long   global
58; CHECK-NEXT:        .long   4
59; CHECK-NEXT:        .byte   0                       # string offset=0
60; CHECK-NEXT:        .ascii  "int"                   # string offset=1
61; CHECK-NEXT:        .byte   0
62; CHECK-NEXT:        .ascii  "test"                  # string offset=5
63; CHECK-NEXT:        .byte   0
64; CHECK-NEXT:        .ascii  ".text"                 # string offset=10
65; CHECK-NEXT:        .byte   0
66; CHECK-NEXT:        .ascii  "/tmp/home/yhs/work/tests/extern/test.c" # string offset=16
67; CHECK-NEXT:        .byte   0
68; CHECK-NEXT:        .ascii  "__t1"                  # string offset=55
69; CHECK-NEXT:        .byte   0
70; CHECK-NEXT:        .ascii  "t1"                    # string offset=60
71; CHECK-NEXT:        .byte   0
72; CHECK-NEXT:        .ascii  "f1"                    # string offset=63
73; CHECK-NEXT:        .byte   0
74; CHECK-NEXT:        .ascii  "global"                # string offset=66
75; CHECK-NEXT:        .byte   0
76; CHECK-NEXT:        .ascii  ".extern"               # string offset=73
77; CHECK-NEXT:        .byte   0
78
79attributes #0 = { norecurse nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
80
81!llvm.dbg.cu = !{!2}
82!llvm.module.flags = !{!11, !12, !13}
83!llvm.ident = !{!14}
84
85!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
86!1 = distinct !DIGlobalVariable(name: "global", scope: !2, file: !3, line: 2, type: !6, isLocal: false, isDefinition: false)
87!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 71a9518c93fe1dce9611c24bc707e5baf1f39f0d)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
88!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/extern")
89!4 = !{}
90!5 = !{!0}
91!6 = !DIDerivedType(tag: DW_TAG_typedef, name: "__t1", file: !3, line: 1, baseType: !7)
92!7 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !3, line: 1, size: 32, elements: !8)
93!8 = !{!9}
94!9 = !DIDerivedType(tag: DW_TAG_member, name: "f1", scope: !7, file: !3, line: 1, baseType: !10, size: 32)
95!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
96!11 = !{i32 7, !"Dwarf Version", i32 4}
97!12 = !{i32 2, !"Debug Info Version", i32 3}
98!13 = !{i32 1, !"wchar_size", i32 4}
99!14 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 71a9518c93fe1dce9611c24bc707e5baf1f39f0d)"}
100!15 = distinct !DISubprogram(name: "test", scope: !3, file: !3, line: 3, type: !16, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
101!16 = !DISubroutineType(types: !17)
102!17 = !{!10}
103!18 = !DILocation(line: 3, column: 28, scope: !15)
104!19 = !{!20, !21, i64 0}
105!20 = !{!"t1", !21, i64 0}
106!21 = !{!"int", !22, i64 0}
107!22 = !{!"omnipotent char", !23, i64 0}
108!23 = !{!"Simple C/C++ TBAA"}
109!24 = !DILocation(line: 3, column: 14, scope: !15)
110