brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · 6bf29d4 Raw
120 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; short a2; } __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;     /* big endian:    r1: 32, r2: 48 */12;     /* little endian: r1: 32, r2: 48 */13;     return r1 + r2;14;   }15; Compilation flag:16;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c17 18target triple = "bpf"19 20%union.u1 = type { %struct.s1 }21%struct.s1 = type { i32, i16 }22 23; Function Attrs: nounwind readnone24define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !11 {25entry:26  call void @llvm.dbg.value(metadata ptr %arg, metadata !27, metadata !DIExpression()), !dbg !3027  %0 = tail call ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr %arg, i32 1), !dbg !31, !llvm.preserve.access.index !1628  %1 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 0), !dbg !32, !llvm.preserve.access.index !2129  %2 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %1, i64 4), !dbg !3330  call void @llvm.dbg.value(metadata i32 %2, metadata !28, metadata !DIExpression()), !dbg !3031  %3 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 1, i32 1), !dbg !34, !llvm.preserve.access.index !2132  %4 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %3, i64 4), !dbg !3533  call void @llvm.dbg.value(metadata i32 %4, metadata !29, metadata !DIExpression()), !dbg !3034  %add = add i32 %4, %2, !dbg !3635  ret i32 %add, !dbg !3736}37 38; CHECK:             r1 = 3239; CHECK:             r0 = 4840; CHECK-ALU64:       r0 += r141; CHECK-ALU32:       w0 += w142; CHECK:             exit43 44; CHECK:             .long   1                       # BTF_KIND_UNION(id = 2)45; CHECK:             .ascii  "u1"                    # string offset=146; CHECK:             .ascii  ".text"                 # string offset=4347; CHECK:             .ascii  "0:1:0"                 # string offset=4948; CHECK:             .ascii  "0:1:1"                 # string offset=9249 50; CHECK:             .long   16                      # FieldReloc51; CHECK-NEXT:        .long   43                      # Field reloc section string offset=4352; CHECK-NEXT:        .long   253; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}54; CHECK-NEXT:        .long   255; CHECK-NEXT:        .long   4956; CHECK-NEXT:        .long   457; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}58; CHECK-NEXT:        .long   259; CHECK-NEXT:        .long   9260; CHECK-NEXT:        .long   461 62; Function Attrs: nounwind readnone63declare ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr, i32)64 65; Function Attrs: nounwind readnone66declare ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr, i32, i32)67 68; Function Attrs: nounwind readnone69declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)70 71; Function Attrs: nounwind readnone72 73; Function Attrs: nounwind readnone74 75; Function Attrs: nounwind readnone speculatable willreturn76declare void @llvm.dbg.value(metadata, metadata, metadata)77 78!llvm.dbg.cu = !{!0}79!llvm.module.flags = !{!7, !8, !9}80!llvm.ident = !{!10}81 82!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)83!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")84!2 = !{!3}85!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 3, baseType: !4, size: 32, elements: !5)86!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)87!5 = !{!6}88!6 = !DIEnumerator(name: "FIELD_LSHIFT_U64", value: 4, isUnsigned: true)89!7 = !{i32 2, !"Dwarf Version", i32 4}90!8 = !{i32 2, !"Debug Info Version", i32 3}91!9 = !{i32 1, !"wchar_size", i32 4}92!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 5635073377f153f7f2ff9b34c77af3c79885ff4a)"}93!11 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 4, type: !12, scopeLine: 4, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !26)94!12 = !DISubroutineType(types: !13)95!13 = !{!14, !15}96!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)97!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)98!16 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1", file: !1, line: 2, size: 64, elements: !17)99!17 = !{!18, !19}100!18 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !16, file: !1, line: 2, baseType: !14, size: 32)101!19 = !DIDerivedType(tag: DW_TAG_member, name: "b2", scope: !16, file: !1, line: 2, baseType: !20, size: 64)102!20 = !DIDerivedType(tag: DW_TAG_typedef, name: "__s1", file: !1, line: 1, baseType: !21)103!21 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 1, size: 64, elements: !22)104!22 = !{!23, !24}105!23 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !21, file: !1, line: 1, baseType: !14, size: 32)106!24 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !21, file: !1, line: 1, baseType: !25, size: 16, offset: 32)107!25 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)108!26 = !{!27, !28, !29}109!27 = !DILocalVariable(name: "arg", arg: 1, scope: !11, file: !1, line: 4, type: !15)110!28 = !DILocalVariable(name: "r1", scope: !11, file: !1, line: 5, type: !4)111!29 = !DILocalVariable(name: "r2", scope: !11, file: !1, line: 6, type: !4)112!30 = !DILocation(line: 0, scope: !11)113!31 = !DILocation(line: 5, column: 52, scope: !11)114!32 = !DILocation(line: 5, column: 55, scope: !11)115!33 = !DILocation(line: 5, column: 17, scope: !11)116!34 = !DILocation(line: 6, column: 55, scope: !11)117!35 = !DILocation(line: 6, column: 17, scope: !11)118!36 = !DILocation(line: 9, column: 13, scope: !11)119!37 = !DILocation(line: 9, column: 3, scope: !11)120