brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.2 KiB · e156999 Raw
214 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;   union sk_buff {6;     int i;7;     struct {8;       int netid;9;       union {10;         int dev_id;11;         int others;12;       } dev;13;     } u;14;   };15;   #define _(x) (__builtin_preserve_access_index(x))16;   static int (*bpf_probe_read)(ptr dst, int size, ptr unsafe_ptr)17;       = (ptr) 4;18;19;   int bpf_prog(union sk_buff *ctx) {20;     int dev_id;21;     bpf_probe_read(&dev_id, sizeof(int), _(&ctx->u.dev.dev_id));22;     return dev_id;23;   }24; Compilation flag:25;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c26 27target triple = "bpf"28 29%union.sk_buff = type { %struct.anon }30%struct.anon = type { i32, %union.anon }31%union.anon = type { i32 }32 33; Function Attrs: nounwind34define dso_local i32 @bpf_prog(ptr) local_unnamed_addr !dbg !15 {35  %2 = alloca i32, align 436  call void @llvm.dbg.value(metadata ptr %0, metadata !32, metadata !DIExpression()), !dbg !3437  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2), !dbg !3538  %3 = tail call ptr @llvm.preserve.union.access.index.p0.sk_buffs.p0.sk_buffs(ptr %0, i32 1), !dbg !36, !llvm.preserve.access.index !1939  %4 = tail call ptr @llvm.preserve.struct.access.index.p0.anons.p0.anons(ptr elementtype(%struct.anon) %3, i32 1, i32 1), !dbg !36, !llvm.preserve.access.index !2340  %5 = tail call ptr @llvm.preserve.union.access.index.p0.anons.p0.anons(ptr %4, i32 0), !dbg !36, !llvm.preserve.access.index !2741  %6 = call i32 inttoptr (i64 4 to ptr)(ptr nonnull %2, i32 4, ptr %5), !dbg !3742  %7 = load i32, ptr %2, align 4, !dbg !38, !tbaa !3943  call void @llvm.dbg.value(metadata i32 %7, metadata !33, metadata !DIExpression()), !dbg !3444  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2), !dbg !4345  ret i32 %7, !dbg !4446}47 48; CHECK:             .section        .BTF,"",@progbits49; CHECK-NEXT:        .short  60319                   # 0xeb9f50; CHECK-NEXT:        .byte   151; CHECK-NEXT:        .byte   052; CHECK-NEXT:        .long   2453; CHECK-NEXT:        .long   054; CHECK-NEXT:        .long   16855; CHECK-NEXT:        .long   16856; CHECK-NEXT:        .long   10557; CHECK-NEXT:        .long   0                       # BTF_KIND_PTR(id = 1)58; CHECK-NEXT:        .long   33554432                # 0x200000059; CHECK-NEXT:        .long   260; CHECK-NEXT:        .long   1                       # BTF_KIND_UNION(id = 2)61; CHECK-NEXT:        .long   83886082                # 0x500000262; CHECK-NEXT:        .long   863; CHECK-NEXT:        .long   964; CHECK-NEXT:        .long   365; CHECK-NEXT:        .long   0                       # 0x066; CHECK-NEXT:        .long   1167; CHECK-NEXT:        .long   468; CHECK-NEXT:        .long   0                       # 0x069; CHECK-NEXT:        .long   13                      # BTF_KIND_INT(id = 3)70; CHECK-NEXT:        .long   16777216                # 0x100000071; CHECK-NEXT:        .long   472; CHECK-NEXT:        .long   16777248                # 0x100002073; CHECK-NEXT:        .long   0                       # BTF_KIND_STRUCT(id = 4)74; CHECK-NEXT:        .long   67108866                # 0x400000275; CHECK-NEXT:        .long   876; CHECK-NEXT:        .long   1777; CHECK-NEXT:        .long   378; CHECK-NEXT:        .long   0                       # 0x079; CHECK-NEXT:        .long   2380; CHECK-NEXT:        .long   581; CHECK-NEXT:        .long   32                      # 0x2082; CHECK-NEXT:        .long   0                       # BTF_KIND_UNION(id = 5)83; CHECK-NEXT:        .long   83886082                # 0x500000284; CHECK-NEXT:        .long   485; CHECK-NEXT:        .long   2786; CHECK-NEXT:        .long   387; CHECK-NEXT:        .long   0                       # 0x088; CHECK-NEXT:        .long   3489; CHECK-NEXT:        .long   390; CHECK-NEXT:        .long   0                       # 0x091; CHECK-NEXT:        .long   0                       # BTF_KIND_FUNC_PROTO(id = 6)92; CHECK-NEXT:        .long   218103809               # 0xd00000193; CHECK-NEXT:        .long   394; CHECK-NEXT:        .long   4195; CHECK-NEXT:        .long   196; CHECK-NEXT:        .long   45                      # BTF_KIND_FUNC(id = 7)97; CHECK-NEXT:        .long   201326593               # 0xc00000198; CHECK-NEXT:        .long   699; CHECK-NEXT:        .byte   0                       # string offset=0100; CHECK-NEXT:        .ascii  "sk_buff"               # string offset=1101; CHECK-NEXT:        .byte   0102; CHECK-NEXT:        .byte   105                     # string offset=9103; CHECK-NEXT:        .byte   0104; CHECK-NEXT:        .byte   117                     # string offset=11105; CHECK-NEXT:        .byte   0106; CHECK-NEXT:        .ascii  "int"                   # string offset=13107; CHECK-NEXT:        .byte   0108; CHECK-NEXT:        .ascii  "netid"                 # string offset=17109; CHECK-NEXT:        .byte   0110; CHECK-NEXT:        .ascii  "dev"                   # string offset=23111; CHECK-NEXT:        .byte   0112; CHECK-NEXT:        .ascii  "dev_id"                # string offset=27113; CHECK-NEXT:        .byte   0114; CHECK-NEXT:        .ascii  "others"                # string offset=34115; CHECK-NEXT:        .byte   0116; CHECK-NEXT:        .ascii  "ctx"                   # string offset=41117; CHECK-NEXT:        .byte   0118; CHECK-NEXT:        .ascii  "bpf_prog"              # string offset=45119; CHECK-NEXT:        .byte   0120; CHECK-NEXT:        .ascii  ".text"                 # string offset=54121; CHECK-NEXT:        .byte   0122; CHECK-NEXT:        .ascii  "/tmp/home/yhs/work/tests/llvm/test.c" # string offset=60123; CHECK-NEXT:        .byte   0124; CHECK-NEXT:        .ascii  "0:1:1:0"               # string offset=97125; CHECK-NEXT:        .byte   0126; CHECK-NEXT:        .section        .BTF.ext,"",@progbits127; CHECK-NEXT:        .short  60319                   # 0xeb9f128; CHECK-NEXT:        .byte   1129; CHECK-NEXT:        .byte   0130; CHECK-NEXT:        .long   32131; CHECK-NEXT:        .long   0132; CHECK-NEXT:        .long   20133; CHECK-NEXT:        .long   20134; CHECK-NEXT:        .long   {{[0-9]+}}135; CHECK-NEXT:        .long   {{[0-9]+}}136; CHECK-NEXT:        .long   28137; CHECK-NEXT:        .long   8                       # FuncInfo138 139; CHECK:             .long   16                      # FieldReloc140; CHECK-NEXT:        .long   54                      # Field reloc section string offset=54141; CHECK-NEXT:        .long   1142; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}143; CHECK-NEXT:        .long   2144; CHECK-NEXT:        .long   97145; CHECK-NEXT:        .long   0146 147; Function Attrs: argmemonly nounwind148declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)149 150; Function Attrs: nounwind readnone151declare ptr @llvm.preserve.union.access.index.p0.sk_buffs.p0.sk_buffs(ptr, i32 immarg)152 153; Function Attrs: nounwind readnone154declare ptr @llvm.preserve.struct.access.index.p0.anons.p0.anons(ptr, i32 immarg, i32 immarg)155 156; Function Attrs: nounwind readnone157declare ptr @llvm.preserve.union.access.index.p0.anons.p0.anons(ptr, i32 immarg)158 159; Function Attrs: argmemonly nounwind160declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)161 162; Function Attrs: nounwind readnone speculatable163declare void @llvm.dbg.value(metadata, metadata, metadata)164 165!llvm.dbg.cu = !{!0}166!llvm.module.flags = !{!11, !12, !13}167!llvm.ident = !{!14}168 169!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)170!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm")171!2 = !{}172!3 = !{!4}173!4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())174!5 = distinct !DIGlobalVariable(name: "bpf_probe_read", scope: !0, file: !1, line: 12, type: !6, isLocal: true, isDefinition: true)175!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)176!7 = !DISubroutineType(types: !8)177!8 = !{!9, !10, !9, !10}178!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)179!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)180!11 = !{i32 2, !"Dwarf Version", i32 4}181!12 = !{i32 2, !"Debug Info Version", i32 3}182!13 = !{i32 1, !"wchar_size", i32 4}183!14 = !{!"clang version 9.0.0 (trunk 360739) (llvm/trunk 360747)"}184!15 = distinct !DISubprogram(name: "bpf_prog", scope: !1, file: !1, line: 15, type: !16, scopeLine: 15, flags: DIFlagPrototyped, isLocal: false, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !31)185!16 = !DISubroutineType(types: !17)186!17 = !{!9, !18}187!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)188!19 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "sk_buff", file: !1, line: 1, size: 64, elements: !20)189!20 = !{!21, !22}190!21 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !19, file: !1, line: 2, baseType: !9, size: 32)191!22 = !DIDerivedType(tag: DW_TAG_member, name: "u", scope: !19, file: !1, line: 9, baseType: !23, size: 64)192!23 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !19, file: !1, line: 3, size: 64, elements: !24)193!24 = !{!25, !26}194!25 = !DIDerivedType(tag: DW_TAG_member, name: "netid", scope: !23, file: !1, line: 4, baseType: !9, size: 32)195!26 = !DIDerivedType(tag: DW_TAG_member, name: "dev", scope: !23, file: !1, line: 8, baseType: !27, size: 32, offset: 32)196!27 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !23, file: !1, line: 5, size: 32, elements: !28)197!28 = !{!29, !30}198!29 = !DIDerivedType(tag: DW_TAG_member, name: "dev_id", scope: !27, file: !1, line: 6, baseType: !9, size: 32)199!30 = !DIDerivedType(tag: DW_TAG_member, name: "others", scope: !27, file: !1, line: 7, baseType: !9, size: 32)200!31 = !{!32, !33}201!32 = !DILocalVariable(name: "ctx", arg: 1, scope: !15, file: !1, line: 15, type: !18)202!33 = !DILocalVariable(name: "dev_id", scope: !15, file: !1, line: 16, type: !9)203!34 = !DILocation(line: 0, scope: !15)204!35 = !DILocation(line: 16, column: 3, scope: !15)205!36 = !DILocation(line: 17, column: 40, scope: !15)206!37 = !DILocation(line: 17, column: 3, scope: !15)207!38 = !DILocation(line: 18, column: 10, scope: !15)208!39 = !{!40, !40, i64 0}209!40 = !{!"int", !41, i64 0}210!41 = !{!"omnipotent char", !42, i64 0}211!42 = !{!"Simple C/C++ TBAA"}212!43 = !DILocation(line: 19, column: 1, scope: !15)213!44 = !DILocation(line: 18, column: 3, scope: !15)214