• 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;   char g __attribute__((weak)) = 2;
6;   int test() {
7;     return g;
8;   }
9; Compilation flag:
10;   clang -target bpf -O2 -g -S -emit-llvm test.c
11
12@g = weak dso_local local_unnamed_addr global i8 2, align 1, !dbg !0
13; Function Attrs: norecurse nounwind readonly
14define dso_local i32 @test() local_unnamed_addr #0 !dbg !11 {
15entry:
16  %0 = load i8, i8* @g, align 1, !dbg !15, !tbaa !16
17  %conv = sext i8 %0 to i32, !dbg !15
18  ret i32 %conv, !dbg !19
19}
20
21; CHECK:             .long   55                      # BTF_KIND_INT(id = 4)
22; CHECK-NEXT:        .long   16777216                # 0x1000000
23; CHECK-NEXT:        .long   1
24; CHECK-NEXT:        .long   16777224                # 0x1000008
25; CHECK-NEXT:        .long   60                      # BTF_KIND_VAR(id = 5)
26; CHECK-NEXT:        .long   234881024               # 0xe000000
27; CHECK-NEXT:        .long   4
28; CHECK-NEXT:        .long   1
29; CHECK-NEXT:        .long   62                      # BTF_KIND_DATASEC(id = 6)
30; CHECK-NEXT:        .long   251658241               # 0xf000001
31; CHECK-NEXT:        .long   0
32; CHECK-NEXT:        .long   5
33; CHECK-NEXT:        .long   g
34; CHECK-NEXT:        .long   1
35
36; CHECK:             .ascii  "char"                  # string offset=55
37; CHECK:             .byte   103                     # string offset=60
38; CHECK:             .ascii  ".data"                 # string offset=62
39
40
41attributes #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" }
42
43!llvm.dbg.cu = !{!2}
44!llvm.module.flags = !{!7, !8, !9}
45!llvm.ident = !{!10}
46
47!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
48!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
49!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git edf6717d8d30034da932b95350898e03c90a5082)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
50!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/global")
51!4 = !{}
52!5 = !{!0}
53!6 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
54!7 = !{i32 7, !"Dwarf Version", i32 4}
55!8 = !{i32 2, !"Debug Info Version", i32 3}
56!9 = !{i32 1, !"wchar_size", i32 4}
57!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git edf6717d8d30034da932b95350898e03c90a5082)"}
58!11 = distinct !DISubprogram(name: "test", scope: !3, file: !3, line: 2, type: !12, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)
59!12 = !DISubroutineType(types: !13)
60!13 = !{!14}
61!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
62!15 = !DILocation(line: 3, column: 10, scope: !11)
63!16 = !{!17, !17, i64 0}
64!17 = !{!"omnipotent char", !18, i64 0}
65!18 = !{!"Simple C/C++ TBAA"}
66!19 = !DILocation(line: 3, column: 3, scope: !11)
67