64 lines · plain
1; RUN: llc -mtriple=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s2; RUN: llc -mtriple=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s3;4; Source code:5; char g __attribute__((weak));6; int test() {7; return g;8; }9; Compilation flag:10; clang -target bpf -O2 -g -S -emit-llvm test.c11 12@g = weak dso_local local_unnamed_addr global i8 0, align 1, !dbg !013; Function Attrs: norecurse nounwind readonly14define dso_local i32 @test() local_unnamed_addr !dbg !11 {15entry:16 %0 = load i8, ptr @g, align 1, !dbg !15, !tbaa !1617 %conv = sext i8 %0 to i32, !dbg !1518 ret i32 %conv, !dbg !1919}20 21; CHECK: .long 55 # BTF_KIND_INT(id = 4)22; CHECK-NEXT: .long 16777216 # 0x100000023; CHECK-NEXT: .long 124; CHECK-NEXT: .long 16777224 # 0x100000825; CHECK-NEXT: .long 60 # BTF_KIND_VAR(id = 5)26; CHECK-NEXT: .long 234881024 # 0xe00000027; CHECK-NEXT: .long 428; CHECK-NEXT: .long 129; CHECK-NEXT: .long 62 # BTF_KIND_DATASEC(id = 6)30; CHECK-NEXT: .long 251658241 # 0xf00000131; CHECK-NEXT: .long 032; CHECK-NEXT: .long 533; CHECK-NEXT: .long g34; CHECK-NEXT: .long 135 36; CHECK: .ascii "char" # string offset=5537; CHECK: .byte 103 # string offset=6038; CHECK: .ascii ".bss" # string offset=6239 40!llvm.dbg.cu = !{!2}41!llvm.module.flags = !{!7, !8, !9}42!llvm.ident = !{!10}43 44!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())45!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)46!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)47!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/global")48!4 = !{}49!5 = !{!0}50!6 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)51!7 = !{i32 7, !"Dwarf Version", i32 4}52!8 = !{i32 2, !"Debug Info Version", i32 3}53!9 = !{i32 1, !"wchar_size", i32 4}54!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git edf6717d8d30034da932b95350898e03c90a5082)"}55!11 = distinct !DISubprogram(name: "test", scope: !3, file: !3, line: 2, type: !12, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4)56!12 = !DISubroutineType(types: !13)57!13 = !{!14}58!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)59!15 = !DILocation(line: 3, column: 10, scope: !11)60!16 = !{!17, !17, i64 0}61!17 = !{!"omnipotent char", !18, i64 0}62!18 = !{!"Simple C/C++ TBAA"}63!19 = !DILocation(line: 3, column: 3, scope: !11)64