brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.3 KiB · 441366f Raw
150 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 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_RSHIFT_U64 = 5, };8;   int test(union u1 *arg) {9;     unsigned r1 = __builtin_preserve_field_info(arg->b2.a1, FIELD_RSHIFT_U64);10;     unsigned r2 = __builtin_preserve_field_info(arg->b2.a2, FIELD_RSHIFT_U64);11;     unsigned r3 = __builtin_preserve_field_info(arg->b2.a3, FIELD_RSHIFT_U64);12;     unsigned r4 = __builtin_preserve_field_info(arg->b2.a4, FIELD_RSHIFT_U64);13;     /* r1: 57, r2: 60, r3: 59, r4: 48 */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%union.u1 = type { i32 }22%struct.s1 = type { i32 }23 24; Function Attrs: nounwind readnone25define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !11 {26entry:27  call void @llvm.dbg.value(metadata ptr %arg, metadata !28, metadata !DIExpression()), !dbg !3328  %0 = tail call ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr %arg, i32 1), !dbg !34, !llvm.preserve.access.index !1629  %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 !2130  %2 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %1, i64 5), !dbg !3631  call void @llvm.dbg.value(metadata i32 %2, metadata !29, metadata !DIExpression()), !dbg !3332  %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 !2133  %4 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %3, i64 5), !dbg !3834  call void @llvm.dbg.value(metadata i32 %4, metadata !30, metadata !DIExpression()), !dbg !3335  %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 !2136  %6 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %5, i64 5), !dbg !4037  call void @llvm.dbg.value(metadata i32 %6, metadata !31, metadata !DIExpression()), !dbg !3338  %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 !2139  %8 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %7, i64 5), !dbg !4240  call void @llvm.dbg.value(metadata i32 %8, metadata !32, metadata !DIExpression()), !dbg !3341  %add = add i32 %4, %2, !dbg !4342  %add4 = add i32 %add, %6, !dbg !4443  %add5 = add i32 %add4, %8, !dbg !4544  ret i32 %add5, !dbg !4645}46 47; CHECK:             r1 = 5748; CHECK:             r0 = 6049; CHECK-ALU64:       r0 += r150; CHECK-ALU32:       w0 += w151; CHECK:             r1 = 5952; CHECK-ALU64:       r0 += r153; CHECK-ALU32:       w0 += w154; CHECK:             r1 = 4855; CHECK-ALU64:       r0 += r156; CHECK-ALU32:       w0 += w157; CHECK:             exit58 59; CHECK:             .long   1                       # BTF_KIND_UNION(id = 2)60; CHECK:             .ascii  "u1"                    # string offset=161; CHECK:             .ascii  ".text"                 # string offset=4362; CHECK:             .ascii  "0:1:0"                 # string offset=4963; CHECK:             .ascii  "0:1:1"                 # string offset=9264; CHECK:             .ascii  "0:1:2"                 # string offset=9865; CHECK:             .ascii  "0:1:3"                 # string offset=10466 67; CHECK:             .long   16                      # FieldReloc68; CHECK-NEXT:        .long   43                      # Field reloc section string offset=4369; CHECK-NEXT:        .long   470; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}71; CHECK-NEXT:        .long   272; CHECK-NEXT:        .long   4973; CHECK-NEXT:        .long   574; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}75; CHECK-NEXT:        .long   276; CHECK-NEXT:        .long   9277; CHECK-NEXT:        .long   578; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}79; CHECK-NEXT:        .long   280; CHECK-NEXT:        .long   9881; CHECK-NEXT:        .long   582; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}83; CHECK-NEXT:        .long   284; CHECK-NEXT:        .long   10485; CHECK-NEXT:        .long   586 87; Function Attrs: nounwind readnone88declare ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr, i32)89 90; Function Attrs: nounwind readnone91declare ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr, i32, i32)92 93; Function Attrs: nounwind readnone94declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)95 96; Function Attrs: nounwind readnone speculatable willreturn97declare void @llvm.dbg.value(metadata, metadata, metadata)98 99!llvm.dbg.cu = !{!0}100!llvm.module.flags = !{!7, !8, !9}101!llvm.ident = !{!10}102 103!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)104!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")105!2 = !{!3}106!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 3, baseType: !4, size: 32, elements: !5)107!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)108!5 = !{!6}109!6 = !DIEnumerator(name: "FIELD_RSHIFT_U64", value: 5, isUnsigned: true)110!7 = !{i32 2, !"Dwarf Version", i32 4}111!8 = !{i32 2, !"Debug Info Version", i32 3}112!9 = !{i32 1, !"wchar_size", i32 4}113!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 4a60741b74384f14b21fdc0131ede326438840ab)"}114!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)115!12 = !DISubroutineType(types: !13)116!13 = !{!14, !15}117!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)118!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)119!16 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1", file: !1, line: 2, size: 32, elements: !17)120!17 = !{!18, !19}121!18 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !16, file: !1, line: 2, baseType: !14, size: 32)122!19 = !DIDerivedType(tag: DW_TAG_member, name: "b2", scope: !16, file: !1, line: 2, baseType: !20, size: 32)123!20 = !DIDerivedType(tag: DW_TAG_typedef, name: "__s1", file: !1, line: 1, baseType: !21)124!21 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 1, size: 32, elements: !22)125!22 = !{!23, !24, !25, !26}126!23 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !21, file: !1, line: 1, baseType: !14, size: 7, flags: DIFlagBitField, extraData: i64 0)127!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)128!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)129!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)130!27 = !{!28, !29, !30, !31, !32}131!28 = !DILocalVariable(name: "arg", arg: 1, scope: !11, file: !1, line: 4, type: !15)132!29 = !DILocalVariable(name: "r1", scope: !11, file: !1, line: 5, type: !4)133!30 = !DILocalVariable(name: "r2", scope: !11, file: !1, line: 6, type: !4)134!31 = !DILocalVariable(name: "r3", scope: !11, file: !1, line: 7, type: !4)135!32 = !DILocalVariable(name: "r4", scope: !11, file: !1, line: 8, type: !4)136!33 = !DILocation(line: 0, scope: !11)137!34 = !DILocation(line: 5, column: 52, scope: !11)138!35 = !DILocation(line: 5, column: 55, scope: !11)139!36 = !DILocation(line: 5, column: 17, scope: !11)140!37 = !DILocation(line: 6, column: 55, scope: !11)141!38 = !DILocation(line: 6, column: 17, scope: !11)142!39 = !DILocation(line: 7, column: 55, scope: !11)143!40 = !DILocation(line: 7, column: 17, scope: !11)144!41 = !DILocation(line: 8, column: 55, scope: !11)145!42 = !DILocation(line: 8, column: 17, scope: !11)146!43 = !DILocation(line: 10, column: 13, scope: !11)147!44 = !DILocation(line: 10, column: 18, scope: !11)148!45 = !DILocation(line: 10, column: 23, scope: !11)149!46 = !DILocation(line: 10, column: 3, scope: !11)150