brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.6 KiB · 0fdd704 Raw
181 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s3; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s4; Source code:5;    struct sk_buff {6;      int i;7;      struct net_device *dev;8;    };9;    #define _(x) (__builtin_preserve_access_index(x))10;    static int (*bpf_probe_read)(ptr dst, int size, ptr unsafe_ptr)11;        = (ptr) 4;12;13;    int bpf_prog(struct sk_buff *ctx) {14;      struct net_device *dev = 0;15;      bpf_probe_read(&dev, sizeof(dev), _(&ctx->dev));16;      return dev != 0;17;    }18; Compilation flag:19;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c20 21target triple = "bpf"22 23%struct.sk_buff = type { i32, ptr }24%struct.net_device = type opaque25 26; Function Attrs: nounwind27define dso_local i32 @bpf_prog(ptr) local_unnamed_addr !dbg !15 {28  %2 = alloca ptr, align 829  call void @llvm.dbg.value(metadata ptr %0, metadata !26, metadata !DIExpression()), !dbg !2830  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2), !dbg !2931  call void @llvm.dbg.value(metadata ptr null, metadata !27, metadata !DIExpression()), !dbg !2832  store ptr null, ptr %2, align 8, !dbg !30, !tbaa !3133  %3 = tail call ptr @llvm.preserve.struct.access.index.p0.net_devices.p0.sk_buffs(ptr elementtype(%struct.sk_buff) %0, i32 1, i32 1), !dbg !35, !llvm.preserve.access.index !1934  %4 = call i32 inttoptr (i64 4 to ptr)(ptr nonnull %2, i32 8, ptr %3), !dbg !3635  %5 = load ptr, ptr %2, align 8, !dbg !37, !tbaa !3136  call void @llvm.dbg.value(metadata ptr %5, metadata !27, metadata !DIExpression()), !dbg !2837  %6 = icmp ne ptr %5, null, !dbg !3838  %7 = zext i1 %6 to i32, !dbg !3839  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2), !dbg !3940  ret i32 %7, !dbg !4041}42 43; CHECK:             .section        .BTF,"",@progbits44; CHECK-NEXT:        .short  60319                   # 0xeb9f45; CHECK-NEXT:        .byte   146; CHECK-NEXT:        .byte   047; CHECK-NEXT:        .long   2448; CHECK-NEXT:        .long   049; CHECK-NEXT:        .long   12050; CHECK-NEXT:        .long   12051; CHECK-NEXT:        .long   9052; CHECK-NEXT:        .long   0                       # BTF_KIND_PTR(id = 1)53; CHECK-NEXT:        .long   33554432                # 0x200000054; CHECK-NEXT:        .long   255; CHECK-NEXT:        .long   1                       # BTF_KIND_STRUCT(id = 2)56; CHECK-NEXT:        .long   67108866                # 0x400000257; CHECK-NEXT:        .long   1658; CHECK-NEXT:        .long   959; CHECK-NEXT:        .long   360; CHECK-NEXT:        .long   0                       # 0x061; CHECK-NEXT:        .long   1162; CHECK-NEXT:        .long   463; CHECK-NEXT:        .long   64                      # 0x4064; CHECK-NEXT:        .long   15                      # BTF_KIND_INT(id = 3)65; CHECK-NEXT:        .long   16777216                # 0x100000066; CHECK-NEXT:        .long   467; CHECK-NEXT:        .long   16777248                # 0x100002068; CHECK-NEXT:        .long   0                       # BTF_KIND_PTR(id = 4)69; CHECK-NEXT:        .long   33554432                # 0x200000070; CHECK-NEXT:        .long   571; CHECK-NEXT:        .long   19                      # BTF_KIND_FWD(id = 5)72; CHECK-NEXT:        .long   117440512               # 0x700000073; CHECK-NEXT:        .long   074; CHECK-NEXT:        .long   0                       # BTF_KIND_FUNC_PROTO(id = 6)75; CHECK-NEXT:        .long   218103809               # 0xd00000176; CHECK-NEXT:        .long   377; CHECK-NEXT:        .long   3078; CHECK-NEXT:        .long   179; CHECK-NEXT:        .long   34                      # BTF_KIND_FUNC(id = 7)80; CHECK-NEXT:        .long   201326593               # 0xc00000181; CHECK-NEXT:        .long   682; CHECK-NEXT:        .byte   0                       # string offset=083; CHECK-NEXT:        .ascii  "sk_buff"               # string offset=184; CHECK-NEXT:        .byte   085; CHECK-NEXT:        .byte   105                     # string offset=986; CHECK-NEXT:        .byte   087; CHECK-NEXT:        .ascii  "dev"                   # string offset=1188; CHECK-NEXT:        .byte   089; CHECK-NEXT:        .ascii  "int"                   # string offset=1590; CHECK-NEXT:        .byte   091; CHECK-NEXT:        .ascii  "net_device"            # string offset=1992; CHECK-NEXT:        .byte   093; CHECK-NEXT:        .ascii  "ctx"                   # string offset=3094; CHECK-NEXT:        .byte   095; CHECK-NEXT:        .ascii  "bpf_prog"              # string offset=3496; CHECK-NEXT:        .byte   097; CHECK-NEXT:        .ascii  ".text"                 # string offset=4398; CHECK-NEXT:        .byte   099; CHECK-NEXT:        .ascii  "/tmp/home/yhs/work/tests/llvm/test.c" # string offset=49100; CHECK-NEXT:        .byte   0101; CHECK-NEXT:        .ascii  "0:1"                   # string offset=86102; CHECK-NEXT:        .byte   0103; CHECK-NEXT:        .section        .BTF.ext,"",@progbits104; CHECK-NEXT:        .short  60319                   # 0xeb9f105; CHECK-NEXT:        .byte   1106; CHECK-NEXT:        .byte   0107; CHECK-NEXT:        .long   32108; CHECK-NEXT:        .long   0109; CHECK-NEXT:        .long   20110; CHECK-NEXT:        .long   20111; CHECK-NEXT:        .long   108112; CHECK-NEXT:        .long   128113; CHECK-NEXT:        .long   28114; CHECK-NEXT:        .long   8                       # FuncInfo115 116; CHECK:             .long   16                      # FieldReloc117; CHECK-NEXT:        .long   43                      # Field reloc section string offset=43118; CHECK-NEXT:        .long   1119; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}120; CHECK-NEXT:        .long   2121; CHECK-NEXT:        .long   86122; CHECK-NEXT:        .long   0123 124; Function Attrs: argmemonly nounwind125declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)126 127; Function Attrs: nounwind readnone128declare ptr @llvm.preserve.struct.access.index.p0.net_devices.p0.sk_buffs(ptr, i32 immarg, i32 immarg)129 130; Function Attrs: argmemonly nounwind131declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)132 133; Function Attrs: nounwind readnone speculatable134declare void @llvm.dbg.value(metadata, metadata, metadata)135 136!llvm.dbg.cu = !{!0}137!llvm.module.flags = !{!11, !12, !13}138!llvm.ident = !{!14}139 140!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (trunk 360739) (llvm/trunk 360747)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, nameTableKind: None)141!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm")142!2 = !{}143!3 = !{!4}144!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())145!5 = distinct !DIGlobalVariable(name: "bpf_probe_read", scope: !0, file: !1, line: 6, type: !6, isLocal: true, isDefinition: true)146!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)147!7 = !DISubroutineType(types: !8)148!8 = !{!9, !10, !9, !10}149!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)150!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)151!11 = !{i32 2, !"Dwarf Version", i32 4}152!12 = !{i32 2, !"Debug Info Version", i32 3}153!13 = !{i32 1, !"wchar_size", i32 4}154!14 = !{!"clang version 9.0.0 (trunk 360739) (llvm/trunk 360747)"}155!15 = distinct !DISubprogram(name: "bpf_prog", scope: !1, file: !1, line: 9, type: !16, scopeLine: 9, flags: DIFlagPrototyped, isLocal: false, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !25)156!16 = !DISubroutineType(types: !17)157!17 = !{!9, !18}158!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)159!19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !1, line: 1, size: 128, elements: !20)160!20 = !{!21, !22}161!21 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !19, file: !1, line: 2, baseType: !9, size: 32)162!22 = !DIDerivedType(tag: DW_TAG_member, name: "dev", scope: !19, file: !1, line: 3, baseType: !23, size: 64, offset: 64)163!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !24, size: 64)164!24 = !DICompositeType(tag: DW_TAG_structure_type, name: "net_device", file: !1, line: 3, flags: DIFlagFwdDecl)165!25 = !{!26, !27}166!26 = !DILocalVariable(name: "ctx", arg: 1, scope: !15, file: !1, line: 9, type: !18)167!27 = !DILocalVariable(name: "dev", scope: !15, file: !1, line: 10, type: !23)168!28 = !DILocation(line: 0, scope: !15)169!29 = !DILocation(line: 10, column: 3, scope: !15)170!30 = !DILocation(line: 10, column: 22, scope: !15)171!31 = !{!32, !32, i64 0}172!32 = !{!"any pointer", !33, i64 0}173!33 = !{!"omnipotent char", !34, i64 0}174!34 = !{!"Simple C/C++ TBAA"}175!35 = !DILocation(line: 11, column: 37, scope: !15)176!36 = !DILocation(line: 11, column: 3, scope: !15)177!37 = !DILocation(line: 12, column: 10, scope: !15)178!38 = !DILocation(line: 12, column: 14, scope: !15)179!39 = !DILocation(line: 13, column: 1, scope: !15)180!40 = !DILocation(line: 12, column: 3, scope: !15)181