brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.4 KiB · c518573 Raw
151 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -mcpu=v1 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK,CHECK-EL,CHECK-ALU64 %s3; RUN: llc -mcpu=v1 -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK,CHECK-EL,CHECK-ALU32 %s4; Source code:5;   typedef struct s1 { int a1:7; int a2:4; int a3:5; int a4:16;} __s1;6;   union u1 { int b1; __s1 b2; };7;   enum { FIELD_LSHIFT_U64 = 4, };8;   int test(union u1 *arg) {9;     unsigned r1 = __builtin_preserve_field_info(arg->b2.a1, FIELD_LSHIFT_U64);10;     unsigned r2 = __builtin_preserve_field_info(arg->b2.a2, FIELD_LSHIFT_U64);11;     unsigned r3 = __builtin_preserve_field_info(arg->b2.a3, FIELD_LSHIFT_U64);12;     unsigned r4 = __builtin_preserve_field_info(arg->b2.a4, FIELD_LSHIFT_U64);13;     /* big endian:    r1: 32, r2: 39, r3: 43, r4: 48 */14;     /* little endian: r1: 57, r2: 53, r3: 48, r4: 32 */15;     return r1 + r2 + r3 + r4;16;   }17; Compilation flag:18;   clang -target bpfel -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c19 20target triple = "bpfel"21 22%union.u1 = type { i32 }23%struct.s1 = type { i32 }24 25; Function Attrs: nounwind readnone26define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !11 {27entry:28  call void @llvm.dbg.value(metadata ptr %arg, metadata !28, metadata !DIExpression()), !dbg !3329  %0 = tail call ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr %arg, i32 1), !dbg !34, !llvm.preserve.access.index !1630  %1 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 0), !dbg !35, !llvm.preserve.access.index !2131  %2 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %1, i64 4), !dbg !3632  call void @llvm.dbg.value(metadata i32 %2, metadata !29, metadata !DIExpression()), !dbg !3333  %3 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 1), !dbg !37, !llvm.preserve.access.index !2134  %4 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %3, i64 4), !dbg !3835  call void @llvm.dbg.value(metadata i32 %4, metadata !30, metadata !DIExpression()), !dbg !3336  %5 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 2), !dbg !39, !llvm.preserve.access.index !2137  %6 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %5, i64 4), !dbg !4038  call void @llvm.dbg.value(metadata i32 %6, metadata !31, metadata !DIExpression()), !dbg !3339  %7 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 3), !dbg !41, !llvm.preserve.access.index !2140  %8 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %7, i64 4), !dbg !4241  call void @llvm.dbg.value(metadata i32 %8, metadata !32, metadata !DIExpression()), !dbg !3342  %add = add i32 %4, %2, !dbg !4343  %add4 = add i32 %add, %6, !dbg !4444  %add5 = add i32 %add4, %8, !dbg !4545  ret i32 %add5, !dbg !4646}47 48; CHECK-EL:          r1 = 5749; CHECK-EL:          r0 = 5350; CHECK-ALU64:       r0 += r151; CHECK-ALU32:       w0 += w152; CHECK-EL:          r1 = 4853; CHECK-ALU64:       r0 += r154; CHECK-ALU32:       w0 += w155; CHECK-EL:          r1 = 3256; CHECK-ALU64:       r0 += r157; CHECK-ALU32:       w0 += w158; CHECK:             exit59 60; CHECK:             .long   1                       # BTF_KIND_UNION(id = 2)61; CHECK:             .ascii  "u1"                    # string offset=162; CHECK:             .ascii  ".text"                 # string offset=4363; CHECK:             .ascii  "0:1:0"                 # string offset=4964; CHECK:             .ascii  "0:1:1"                 # string offset=9265; CHECK:             .ascii  "0:1:2"                 # string offset=9866; CHECK:             .ascii  "0:1:3"                 # string offset=10467 68; CHECK:             .long   16                      # FieldReloc69; CHECK-NEXT:        .long   43                      # Field reloc section string offset=4370; CHECK-NEXT:        .long   471; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}72; CHECK-NEXT:        .long   273; CHECK-NEXT:        .long   4974; CHECK-NEXT:        .long   475; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}76; CHECK-NEXT:        .long   277; CHECK-NEXT:        .long   9278; CHECK-NEXT:        .long   479; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}80; CHECK-NEXT:        .long   281; CHECK-NEXT:        .long   9882; CHECK-NEXT:        .long   483; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}84; CHECK-NEXT:        .long   285; CHECK-NEXT:        .long   10486; CHECK-NEXT:        .long   487 88; Function Attrs: nounwind readnone89declare ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr, i32)90 91; Function Attrs: nounwind readnone92declare ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr, i32, i32)93 94; Function Attrs: nounwind readnone95declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)96 97; Function Attrs: nounwind readnone speculatable willreturn98declare void @llvm.dbg.value(metadata, metadata, metadata)99 100!llvm.dbg.cu = !{!0}101!llvm.module.flags = !{!7, !8, !9}102!llvm.ident = !{!10}103 104!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 5635073377f153f7f2ff9b34c77af3c79885ff4a)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)105!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")106!2 = !{!3}107!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 3, baseType: !4, size: 32, elements: !5)108!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)109!5 = !{!6}110!6 = !DIEnumerator(name: "FIELD_LSHIFT_U64", value: 4, isUnsigned: true)111!7 = !{i32 2, !"Dwarf Version", i32 4}112!8 = !{i32 2, !"Debug Info Version", i32 3}113!9 = !{i32 1, !"wchar_size", i32 4}114!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 5635073377f153f7f2ff9b34c77af3c79885ff4a)"}115!11 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 4, type: !12, scopeLine: 4, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !27)116!12 = !DISubroutineType(types: !13)117!13 = !{!14, !15}118!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)119!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)120!16 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1", file: !1, line: 2, size: 32, elements: !17)121!17 = !{!18, !19}122!18 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !16, file: !1, line: 2, baseType: !14, size: 32)123!19 = !DIDerivedType(tag: DW_TAG_member, name: "b2", scope: !16, file: !1, line: 2, baseType: !20, size: 32)124!20 = !DIDerivedType(tag: DW_TAG_typedef, name: "__s1", file: !1, line: 1, baseType: !21)125!21 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 1, size: 32, elements: !22)126!22 = !{!23, !24, !25, !26}127!23 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !21, file: !1, line: 1, baseType: !14, size: 7, flags: DIFlagBitField, extraData: i64 0)128!24 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !21, file: !1, line: 1, baseType: !14, size: 4, offset: 7, flags: DIFlagBitField, extraData: i64 0)129!25 = !DIDerivedType(tag: DW_TAG_member, name: "a3", scope: !21, file: !1, line: 1, baseType: !14, size: 5, offset: 11, flags: DIFlagBitField, extraData: i64 0)130!26 = !DIDerivedType(tag: DW_TAG_member, name: "a4", scope: !21, file: !1, line: 1, baseType: !14, size: 16, offset: 16, flags: DIFlagBitField, extraData: i64 0)131!27 = !{!28, !29, !30, !31, !32}132!28 = !DILocalVariable(name: "arg", arg: 1, scope: !11, file: !1, line: 4, type: !15)133!29 = !DILocalVariable(name: "r1", scope: !11, file: !1, line: 5, type: !4)134!30 = !DILocalVariable(name: "r2", scope: !11, file: !1, line: 6, type: !4)135!31 = !DILocalVariable(name: "r3", scope: !11, file: !1, line: 7, type: !4)136!32 = !DILocalVariable(name: "r4", scope: !11, file: !1, line: 8, type: !4)137!33 = !DILocation(line: 0, scope: !11)138!34 = !DILocation(line: 5, column: 52, scope: !11)139!35 = !DILocation(line: 5, column: 55, scope: !11)140!36 = !DILocation(line: 5, column: 17, scope: !11)141!37 = !DILocation(line: 6, column: 55, scope: !11)142!38 = !DILocation(line: 6, column: 17, scope: !11)143!39 = !DILocation(line: 7, column: 55, scope: !11)144!40 = !DILocation(line: 7, column: 17, scope: !11)145!41 = !DILocation(line: 8, column: 55, scope: !11)146!42 = !DILocation(line: 8, column: 17, scope: !11)147!43 = !DILocation(line: 11, column: 13, scope: !11)148!44 = !DILocation(line: 11, column: 18, scope: !11)149!45 = !DILocation(line: 11, column: 23, scope: !11)150!46 = !DILocation(line: 11, column: 3, scope: !11)151