brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.6 KiB · 0404deb Raw
160 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -mcpu=v1 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK,CHECK-ALU64 %s3; RUN: llc -mcpu=v1 -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK,CHECK-ALU32 %s4; Source code:5;   typedef unsigned __uint;6;   struct s1 { int a1; __uint a2:9; __uint a3:4; };7;   union u1 { int b1; __uint b2:9; __uint b3:4; };8;   enum { FIELD_EXISTENCE = 2, };9;   int test(struct s1 *arg1, union u1 *arg2) {10;     unsigned r1 = __builtin_preserve_field_info(arg1->a1, FIELD_EXISTENCE);11;     unsigned r2 = __builtin_preserve_field_info(arg1->a3, FIELD_EXISTENCE);12;     unsigned r3 = __builtin_preserve_field_info(arg2->b1, FIELD_EXISTENCE);13;     unsigned r4 = __builtin_preserve_field_info(arg2->b3, FIELD_EXISTENCE);14;     return r1 + r2 + r3 + r4;15;   }16; Compilation flag:17;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c18 19target triple = "bpf"20 21%struct.s1 = type { i32, i16 }22%union.u1 = type { i32 }23 24; Function Attrs: nounwind readnone25define dso_local i32 @test(ptr %arg1, ptr %arg2) local_unnamed_addr !dbg !11 {26entry:27  call void @llvm.dbg.value(metadata ptr %arg1, metadata !29, metadata !DIExpression()), !dbg !3528  call void @llvm.dbg.value(metadata ptr %arg2, metadata !30, metadata !DIExpression()), !dbg !3529  %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %arg1, i32 0, i32 0), !dbg !36, !llvm.preserve.access.index !1630  %1 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %0, i64 2), !dbg !3731  call void @llvm.dbg.value(metadata i32 %1, metadata !31, metadata !DIExpression()), !dbg !3532  %2 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %arg1, i32 1, i32 2), !dbg !38, !llvm.preserve.access.index !1633  %3 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %2, i64 2), !dbg !3934  call void @llvm.dbg.value(metadata i32 %3, metadata !32, metadata !DIExpression()), !dbg !3535  %4 = tail call ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr %arg2, i32 0), !dbg !40, !llvm.preserve.access.index !2336  %5 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %4, i64 2), !dbg !4137  call void @llvm.dbg.value(metadata i32 %5, metadata !33, metadata !DIExpression()), !dbg !3538  %6 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.u1s(ptr elementtype(%union.u1) %arg2, i32 0, i32 2), !dbg !42, !llvm.preserve.access.index !2339  %7 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %6, i64 2), !dbg !4340  call void @llvm.dbg.value(metadata i32 %7, metadata !34, metadata !DIExpression()), !dbg !3541  %add = add i32 %3, %1, !dbg !4442  %add1 = add i32 %add, %5, !dbg !4543  %add2 = add i32 %add1, %7, !dbg !4644  ret i32 %add2, !dbg !4745}46 47; CHECK:             r1 = 148; CHECK:             r0 = 149; CHECK-ALU64:       r0 += r150; CHECK-ALU32:       w0 += w151; CHECK:             r1 = 152; CHECK-ALU64:       r0 += r153; CHECK-ALU32:       w0 += w154; CHECK:             r1 = 155; CHECK-ALU64:       r0 += r156; CHECK-ALU32:       w0 += w157; CHECK:             exit58 59; CHECK:             .long   1                       # BTF_KIND_STRUCT(id = 2)60; CHECK:             .long   37                      # BTF_KIND_UNION(id = 7)61; CHECK:             .ascii  "s1"                    # string offset=162; CHECK:             .ascii  "u1"                    # string offset=3763; CHECK:             .ascii  ".text"                 # string offset=6464; CHECK:             .ascii  "0:0"                   # string offset=7065; CHECK:             .ascii  "0:2"                   # string offset=11166 67; CHECK:             .long   16                      # FieldReloc68; CHECK-NEXT:        .long   64                      # Field reloc section string offset=6469; CHECK-NEXT:        .long   470; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}71; CHECK-NEXT:        .long   272; CHECK-NEXT:        .long   7073; CHECK-NEXT:        .long   274; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}75; CHECK-NEXT:        .long   276; CHECK-NEXT:        .long   11177; CHECK-NEXT:        .long   278; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}79; CHECK-NEXT:        .long   780; CHECK-NEXT:        .long   7081; CHECK-NEXT:        .long   282; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}83; CHECK-NEXT:        .long   784; CHECK-NEXT:        .long   11185; CHECK-NEXT:        .long   286 87; Function Attrs: nounwind readnone88declare ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr, i32, i32)89 90; Function Attrs: nounwind readnone91declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)92 93; Function Attrs: nounwind readnone94 95; Function Attrs: nounwind readnone96 97; Function Attrs: nounwind readnone98declare ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr, i32)99 100; Function Attrs: nounwind readnone101declare ptr @llvm.preserve.struct.access.index.p0.p0.u1s(ptr, i32, i32)102 103; Function Attrs: nounwind readnone104 105; Function Attrs: nounwind readnone speculatable willreturn106declare void @llvm.dbg.value(metadata, metadata, metadata)107 108!llvm.dbg.cu = !{!0}109!llvm.module.flags = !{!7, !8, !9}110!llvm.ident = !{!10}111 112!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 4a60741b74384f14b21fdc0131ede326438840ab)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)113!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")114!2 = !{!3}115!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 4, baseType: !4, size: 32, elements: !5)116!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)117!5 = !{!6}118!6 = !DIEnumerator(name: "FIELD_EXISTENCE", value: 2, isUnsigned: true)119!7 = !{i32 2, !"Dwarf Version", i32 4}120!8 = !{i32 2, !"Debug Info Version", i32 3}121!9 = !{i32 1, !"wchar_size", i32 4}122!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 4a60741b74384f14b21fdc0131ede326438840ab)"}123!11 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 5, type: !12, scopeLine: 5, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !28)124!12 = !DISubroutineType(types: !13)125!13 = !{!14, !15, !22}126!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)127!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)128!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 2, size: 64, elements: !17)129!17 = !{!18, !19, !21}130!18 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !16, file: !1, line: 2, baseType: !14, size: 32)131!19 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !16, file: !1, line: 2, baseType: !20, size: 9, offset: 32, flags: DIFlagBitField, extraData: i64 32)132!20 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint", file: !1, line: 1, baseType: !4)133!21 = !DIDerivedType(tag: DW_TAG_member, name: "a3", scope: !16, file: !1, line: 2, baseType: !20, size: 4, offset: 41, flags: DIFlagBitField, extraData: i64 32)134!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64)135!23 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1", file: !1, line: 3, size: 32, elements: !24)136!24 = !{!25, !26, !27}137!25 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !23, file: !1, line: 3, baseType: !14, size: 32)138!26 = !DIDerivedType(tag: DW_TAG_member, name: "b2", scope: !23, file: !1, line: 3, baseType: !20, size: 9, flags: DIFlagBitField, extraData: i64 0)139!27 = !DIDerivedType(tag: DW_TAG_member, name: "b3", scope: !23, file: !1, line: 3, baseType: !20, size: 4, flags: DIFlagBitField, extraData: i64 0)140!28 = !{!29, !30, !31, !32, !33, !34}141!29 = !DILocalVariable(name: "arg1", arg: 1, scope: !11, file: !1, line: 5, type: !15)142!30 = !DILocalVariable(name: "arg2", arg: 2, scope: !11, file: !1, line: 5, type: !22)143!31 = !DILocalVariable(name: "r1", scope: !11, file: !1, line: 6, type: !4)144!32 = !DILocalVariable(name: "r2", scope: !11, file: !1, line: 7, type: !4)145!33 = !DILocalVariable(name: "r3", scope: !11, file: !1, line: 8, type: !4)146!34 = !DILocalVariable(name: "r4", scope: !11, file: !1, line: 9, type: !4)147!35 = !DILocation(line: 0, scope: !11)148!36 = !DILocation(line: 6, column: 53, scope: !11)149!37 = !DILocation(line: 6, column: 17, scope: !11)150!38 = !DILocation(line: 7, column: 53, scope: !11)151!39 = !DILocation(line: 7, column: 17, scope: !11)152!40 = !DILocation(line: 8, column: 53, scope: !11)153!41 = !DILocation(line: 8, column: 17, scope: !11)154!42 = !DILocation(line: 9, column: 53, scope: !11)155!43 = !DILocation(line: 9, column: 17, scope: !11)156!44 = !DILocation(line: 10, column: 13, scope: !11)157!45 = !DILocation(line: 10, column: 18, scope: !11)158!46 = !DILocation(line: 10, column: 23, scope: !11)159!47 = !DILocation(line: 10, column: 3, scope: !11)160