brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · 0220567 Raw
84 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;   typedef struct s1 { int a1; int a2:4; int a3;} __s1;6;   enum { FIELD_BYTE_SIZE = 1, };7;   int test(__s1 *arg) {8;     return __builtin_preserve_field_info(arg->a2, FIELD_BYTE_SIZE);9;   }10; Compilation flag:11;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c12 13target triple = "bpf"14 15%struct.s1 = type { i32, i8, i32 }16 17; Function Attrs: nounwind readnone18define dso_local i32 @test(ptr readnone %arg) local_unnamed_addr !dbg !11 {19entry:20  call void @llvm.dbg.value(metadata ptr %arg, metadata !23, metadata !DIExpression()), !dbg !2421  %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %arg, i32 1, i32 1), !dbg !25, !llvm.preserve.access.index !1722  %1 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %0, i64 1), !dbg !2623  ret i32 %1, !dbg !2724}25 26; CHECK:             r0 = 427; CHECK:             exit28 29; CHECK:             .long   6                       # BTF_KIND_STRUCT(id = 3)30 31; CHECK:             .ascii  "s1"                    # string offset=632; CHECK:             .ascii  ".text"                 # string offset=3133; CHECK:             .ascii  "0:1"                   # string offset=3734 35; CHECK:             .long   16                      # FieldReloc36; CHECK-NEXT:        .long   31                      # Field reloc section string offset=3137; CHECK-NEXT:        .long   138; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}39; CHECK-NEXT:        .long   340; CHECK-NEXT:        .long   3741; CHECK-NEXT:        .long   142 43; Function Attrs: nounwind readnone44declare ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr, i32, i32)45 46; Function Attrs: nounwind readnone47declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)48 49; Function Attrs: nounwind readnone speculatable50declare void @llvm.dbg.value(metadata, metadata, metadata)51 52!llvm.dbg.cu = !{!0}53!llvm.module.flags = !{!7, !8, !9}54!llvm.ident = !{!10}55 56!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 6c63b5d6a1cb84a75807804337c855a41c976260)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)57!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")58!2 = !{!3}59!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 2, baseType: !4, size: 32, elements: !5)60!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)61!5 = !{!6}62!6 = !DIEnumerator(name: "FIELD_BYTE_SIZE", value: 1, isUnsigned: true)63!7 = !{i32 2, !"Dwarf Version", i32 4}64!8 = !{i32 2, !"Debug Info Version", i32 3}65!9 = !{i32 1, !"wchar_size", i32 4}66!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 6c63b5d6a1cb84a75807804337c855a41c976260)"}67!11 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, type: !12, scopeLine: 3, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !22)68!12 = !DISubroutineType(types: !13)69!13 = !{!14, !15}70!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)71!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)72!16 = !DIDerivedType(tag: DW_TAG_typedef, name: "__s1", file: !1, line: 1, baseType: !17)73!17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 1, size: 96, elements: !18)74!18 = !{!19, !20, !21}75!19 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !17, file: !1, line: 1, baseType: !14, size: 32)76!20 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !17, file: !1, line: 1, baseType: !14, size: 4, offset: 32, flags: DIFlagBitField, extraData: i64 32)77!21 = !DIDerivedType(tag: DW_TAG_member, name: "a3", scope: !17, file: !1, line: 1, baseType: !14, size: 32, offset: 64)78!22 = !{!23}79!23 = !DILocalVariable(name: "arg", arg: 1, scope: !11, file: !1, line: 3, type: !15)80!24 = !DILocation(line: 0, scope: !11)81!25 = !DILocation(line: 4, column: 45, scope: !11)82!26 = !DILocation(line: 4, column: 10, scope: !11)83!27 = !DILocation(line: 4, column: 3, scope: !11)84