summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/BPF/BTF/extern-global-var.ll
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/CodeGen/BPF/BTF/extern-global-var.ll')
-rw-r--r--llvm/test/CodeGen/BPF/BTF/extern-global-var.ll69
1 files changed, 69 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/BPF/BTF/extern-global-var.ll b/llvm/test/CodeGen/BPF/BTF/extern-global-var.ll
new file mode 100644
index 00000000000..ad81d28a657
--- /dev/null
+++ b/llvm/test/CodeGen/BPF/BTF/extern-global-var.ll
@@ -0,0 +1,69 @@
+; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s
+
+; Source code:
+; extern char a;
+; int foo() { return a; }
+; Compilation flag:
+; clang -target bpf -O2 -g -S -emit-llvm test.c
+
+@a = external dso_local local_unnamed_addr global i8, align 1
+
+; Function Attrs: norecurse nounwind readonly
+define dso_local i32 @foo() local_unnamed_addr #0 !dbg !7 {
+ %1 = load i8, i8* @a, align 1, !dbg !11, !tbaa !12
+ %2 = sext i8 %1 to i32, !dbg !11
+ ret i32 %2, !dbg !15
+}
+
+; CHECK: .section .BTF,"",@progbits
+; CHECK-NEXT: .short 60319 # 0xeb9f
+; CHECK-NEXT: .byte 1
+; CHECK-NEXT: .byte 0
+; CHECK-NEXT: .long 24
+; CHECK-NEXT: .long 0
+; CHECK-NEXT: .long 40
+; CHECK-NEXT: .long 40
+; CHECK-NEXT: .long 52
+; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1)
+; CHECK-NEXT: .long 218103808 # 0xd000000
+; CHECK-NEXT: .long 2
+; CHECK-NEXT: .long 44 # BTF_KIND_INT(id = 2)
+; CHECK-NEXT: .long 16777216 # 0x1000000
+; CHECK-NEXT: .long 4
+; CHECK-NEXT: .long 16777248 # 0x1000020
+; CHECK-NEXT: .long 48 # BTF_KIND_FUNC(id = 3)
+; CHECK-NEXT: .long 201326592 # 0xc000000
+; CHECK-NEXT: .long 1
+; CHECK-NEXT: .byte 0 # string offset=0
+; CHECK-NEXT: .ascii ".text" # string offset=1
+; CHECK-NEXT: .byte 0
+; CHECK-NEXT: .ascii "/home/yhs/work/tests/llvm/bug/test.c" # string offset=7
+; CHECK-NEXT: .byte 0
+; CHECK-NEXT: .ascii "int" # string offset=44
+; CHECK-NEXT: .byte 0
+; CHECK-NEXT: .ascii "foo" # string offset=48
+; CHECK-NEXT: .byte 0
+
+attributes #0 = { norecurse nounwind readonly "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" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!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)
+!1 = !DIFile(filename: "test.c", directory: "/home/yhs/work/tests/llvm/bug")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 8.0.20181009 "}
+!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, retainedNodes: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{!10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !DILocation(line: 2, column: 20, scope: !7)
+!12 = !{!13, !13, i64 0}
+!13 = !{!"omnipotent char", !14, i64 0}
+!14 = !{!"Simple C/C++ TBAA"}
+!15 = !DILocation(line: 2, column: 13, scope: !7)
OpenPOWER on IntegriCloud