brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.0 KiB · 312d40f 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;   enum A { AA = -1, AB = 0, }; /* signed */6;   enum B { BA = 0, BB = 1, };  /* unsigned */7;   typedef enum A __A;8;   typedef enum B __B;9;   typedef int __int;           /* signed */10;   struct s1 { __A a1; __B a2:9; __int a3:4; };11;   union u1 { int b1; struct s1 b2; };12;   enum { FIELD_SIGNEDNESS = 3, };13;   int test(union u1 *arg) {14;     unsigned r1 = __builtin_preserve_field_info(arg->b2.a1, FIELD_SIGNEDNESS);15;     unsigned r2 = __builtin_preserve_field_info(arg->b2.a2, FIELD_SIGNEDNESS);16;     unsigned r3 = __builtin_preserve_field_info(arg->b2.a3, FIELD_SIGNEDNESS);17;     return r1 + r2 + r3;18;   }19; Compilation flag:20;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c21 22target triple = "bpf"23 24%union.u1 = type { %struct.s1 }25%struct.s1 = type { i32, i16 }26 27; Function Attrs: nounwind readnone28define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !20 {29entry:30  call void @llvm.dbg.value(metadata ptr %arg, metadata !37, metadata !DIExpression()), !dbg !4131  %0 = tail call ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr %arg, i32 1), !dbg !42, !llvm.preserve.access.index !2432  %1 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 0), !dbg !43, !llvm.preserve.access.index !2833  %2 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %1, i64 3), !dbg !4434  call void @llvm.dbg.value(metadata i32 %2, metadata !38, metadata !DIExpression()), !dbg !4135  %3 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 1, i32 1), !dbg !45, !llvm.preserve.access.index !2836  %4 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %3, i64 3), !dbg !4637  call void @llvm.dbg.value(metadata i32 %4, metadata !39, metadata !DIExpression()), !dbg !4138  %5 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 1, i32 2), !dbg !47, !llvm.preserve.access.index !2839  %6 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %5, i64 3), !dbg !4840  call void @llvm.dbg.value(metadata i32 %6, metadata !40, metadata !DIExpression()), !dbg !4141  %add = add i32 %4, %2, !dbg !4942  %add3 = add i32 %add, %6, !dbg !5043  ret i32 %add3, !dbg !5144}45 46; CHECK:             r1 = 147; CHECK:             r0 = 048; CHECK-ALU64:       r0 += r149; CHECK-ALU32:       w0 += w150; CHECK:             r1 = 151; CHECK-ALU64:       r0 += r152; CHECK-ALU32:       w0 += w153; CHECK:             exit54 55; CHECK:             .long   1                       # BTF_KIND_UNION(id = 2)56; CHECK:             .ascii  "u1"                    # string offset=157; CHECK:             .ascii  ".text"                 # string offset=6558; CHECK:             .ascii  "0:1:0"                 # string offset=7159; CHECK:             .ascii  "0:1:1"                 # string offset=11460; CHECK:             .ascii  "0:1:2"                 # string offset=12061 62; CHECK:             .long   16                      # FieldReloc63; CHECK-NEXT:        .long   65                      # Field reloc section string offset=6564; CHECK-NEXT:        .long   365; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}66; CHECK-NEXT:        .long   267; CHECK-NEXT:        .long   7168; CHECK-NEXT:        .long   369; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}70; CHECK-NEXT:        .long   271; CHECK-NEXT:        .long   11472; CHECK-NEXT:        .long   373; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}74; CHECK-NEXT:        .long   275; CHECK-NEXT:        .long   12076; CHECK-NEXT:        .long   377 78; Function Attrs: nounwind readnone79declare ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr, i32)80 81; Function Attrs: nounwind readnone82declare ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr, i32, i32)83 84; Function Attrs: nounwind readnone85declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)86 87; Function Attrs: nounwind readnone88 89; Function Attrs: nounwind readnone90 91; Function Attrs: nounwind readnone speculatable willreturn92declare void @llvm.dbg.value(metadata, metadata, metadata)93 94!llvm.dbg.cu = !{!0}95!llvm.module.flags = !{!16, !17, !18}96!llvm.ident = !{!19}97 98!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)99!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")100!2 = !{!3, !8, !13}101!3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "A", file: !1, line: 1, baseType: !4, size: 32, elements: !5)102!4 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)103!5 = !{!6, !7}104!6 = !DIEnumerator(name: "AA", value: -1)105!7 = !DIEnumerator(name: "AB", value: 0)106!8 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "B", file: !1, line: 2, baseType: !9, size: 32, elements: !10)107!9 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)108!10 = !{!11, !12}109!11 = !DIEnumerator(name: "BA", value: 0, isUnsigned: true)110!12 = !DIEnumerator(name: "BB", value: 1, isUnsigned: true)111!13 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 8, baseType: !9, size: 32, elements: !14)112!14 = !{!15}113!15 = !DIEnumerator(name: "FIELD_SIGNEDNESS", value: 3, isUnsigned: true)114!16 = !{i32 2, !"Dwarf Version", i32 4}115!17 = !{i32 2, !"Debug Info Version", i32 3}116!18 = !{i32 1, !"wchar_size", i32 4}117!19 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 4a60741b74384f14b21fdc0131ede326438840ab)"}118!20 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 9, type: !21, scopeLine: 9, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !36)119!21 = !DISubroutineType(types: !22)120!22 = !{!4, !23}121!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !24, size: 64)122!24 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1", file: !1, line: 7, size: 64, elements: !25)123!25 = !{!26, !27}124!26 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !24, file: !1, line: 7, baseType: !4, size: 32)125!27 = !DIDerivedType(tag: DW_TAG_member, name: "b2", scope: !24, file: !1, line: 7, baseType: !28, size: 64)126!28 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 6, size: 64, elements: !29)127!29 = !{!30, !32, !34}128!30 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !28, file: !1, line: 6, baseType: !31, size: 32)129!31 = !DIDerivedType(tag: DW_TAG_typedef, name: "__A", file: !1, line: 3, baseType: !3)130!32 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !28, file: !1, line: 6, baseType: !33, size: 9, offset: 32, flags: DIFlagBitField, extraData: i64 32)131!33 = !DIDerivedType(tag: DW_TAG_typedef, name: "__B", file: !1, line: 4, baseType: !8)132!34 = !DIDerivedType(tag: DW_TAG_member, name: "a3", scope: !28, file: !1, line: 6, baseType: !35, size: 4, offset: 41, flags: DIFlagBitField, extraData: i64 32)133!35 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int", file: !1, line: 5, baseType: !4)134!36 = !{!37, !38, !39, !40}135!37 = !DILocalVariable(name: "arg", arg: 1, scope: !20, file: !1, line: 9, type: !23)136!38 = !DILocalVariable(name: "r1", scope: !20, file: !1, line: 10, type: !9)137!39 = !DILocalVariable(name: "r2", scope: !20, file: !1, line: 11, type: !9)138!40 = !DILocalVariable(name: "r3", scope: !20, file: !1, line: 12, type: !9)139!41 = !DILocation(line: 0, scope: !20)140!42 = !DILocation(line: 10, column: 52, scope: !20)141!43 = !DILocation(line: 10, column: 55, scope: !20)142!44 = !DILocation(line: 10, column: 17, scope: !20)143!45 = !DILocation(line: 11, column: 55, scope: !20)144!46 = !DILocation(line: 11, column: 17, scope: !20)145!47 = !DILocation(line: 12, column: 55, scope: !20)146!48 = !DILocation(line: 12, column: 17, scope: !20)147!49 = !DILocation(line: 13, column: 13, scope: !20)148!50 = !DILocation(line: 13, column: 18, scope: !20)149!51 = !DILocation(line: 13, column: 3, scope: !20)150