brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.9 KiB · 2697201 Raw
137 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; char a2; } __s1;6;   union u1 { int b1; __s1 b2; };7;   enum { FIELD_BYTE_SIZE = 1, };8;   int test(union u1 *arg) {9;     unsigned r1 = __builtin_preserve_field_info(arg->b2, FIELD_BYTE_SIZE);10;     unsigned r2 = __builtin_preserve_field_info(arg->b2.a1, FIELD_BYTE_SIZE);11;     unsigned r3 = __builtin_preserve_field_info(arg->b2.a2, FIELD_BYTE_SIZE);12;     /* r1: 8, r2: 4, r3: 1 */13;     return r1 + r2 + r3;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, i8 }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 !3127  %0 = tail call ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr %arg, i32 1), !dbg !32, !llvm.preserve.access.index !1628  %1 = tail call i32 @llvm.bpf.preserve.field.info.p0.s1s(ptr %0, i64 1), !dbg !3329  call void @llvm.dbg.value(metadata i32 %1, metadata !28, metadata !DIExpression()), !dbg !3130  %2 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 0), !dbg !34, !llvm.preserve.access.index !2131  %3 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %2, i64 1), !dbg !3532  call void @llvm.dbg.value(metadata i32 %3, metadata !29, metadata !DIExpression()), !dbg !3133  %4 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr elementtype(%struct.s1) %0, i32 1, i32 1), !dbg !36, !llvm.preserve.access.index !2134  %5 = tail call i32 @llvm.bpf.preserve.field.info.p0(ptr %4, i64 1), !dbg !3735  call void @llvm.dbg.value(metadata i32 %5, metadata !30, metadata !DIExpression()), !dbg !3136  %add = add i32 %3, %1, !dbg !3837  %add3 = add i32 %add, %5, !dbg !3938  ret i32 %add3, !dbg !4039}40 41; CHECK:             r1 = 842; CHECK:             r0 = 443; CHECK-ALU64:       r0 += r144; CHECK-ALU32:       w0 += w145; CHECK:             r1 = 146; CHECK-ALU64:       r0 += r147; CHECK-ALU32:       w0 += w148; CHECK:             exit49 50; CHECK:             .long   1                       # BTF_KIND_UNION(id = 2)51; CHECK:             .ascii  "u1"                    # string offset=152; CHECK:             .ascii  ".text"                 # string offset=4253; CHECK:             .ascii  "0:1"                   # string offset=4854; CHECK:             .ascii  "0:1:0"                 # string offset=8955; CHECK:             .ascii  "0:1:1"                 # string offset=9556 57; CHECK:             .long   16                      # FieldReloc58; CHECK-NEXT:        .long   42                      # Field reloc section string offset=4259; CHECK-NEXT:        .long   360; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}61; CHECK-NEXT:        .long   262; CHECK-NEXT:        .long   4863; CHECK-NEXT:        .long   164; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}65; CHECK-NEXT:        .long   266; CHECK-NEXT:        .long   8967; CHECK-NEXT:        .long   168; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}69; CHECK-NEXT:        .long   270; CHECK-NEXT:        .long   9571; CHECK-NEXT:        .long   172 73; Function Attrs: nounwind readnone74declare ptr @llvm.preserve.union.access.index.p0.u1s.p0.u1s(ptr, i32)75 76; Function Attrs: nounwind readnone77declare i32 @llvm.bpf.preserve.field.info.p0.s1s(ptr, i64)78 79; Function Attrs: nounwind readnone80declare ptr @llvm.preserve.struct.access.index.p0.p0.s1s(ptr, i32, i32)81 82; Function Attrs: nounwind readnone83declare i32 @llvm.bpf.preserve.field.info.p0(ptr, i64)84 85; Function Attrs: nounwind readnone86 87; Function Attrs: nounwind readnone88 89; Function Attrs: nounwind readnone speculatable willreturn90declare void @llvm.dbg.value(metadata, metadata, metadata)91 92!llvm.dbg.cu = !{!0}93!llvm.module.flags = !{!7, !8, !9}94!llvm.ident = !{!10}95 96!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)97!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")98!2 = !{!3}99!3 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !1, line: 3, baseType: !4, size: 32, elements: !5)100!4 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)101!5 = !{!6}102!6 = !DIEnumerator(name: "FIELD_BYTE_SIZE", value: 1, isUnsigned: true)103!7 = !{i32 2, !"Dwarf Version", i32 4}104!8 = !{i32 2, !"Debug Info Version", i32 3}105!9 = !{i32 1, !"wchar_size", i32 4}106!10 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 4a60741b74384f14b21fdc0131ede326438840ab)"}107!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)108!12 = !DISubroutineType(types: !13)109!13 = !{!14, !15}110!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)111!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)112!16 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1", file: !1, line: 2, size: 64, elements: !17)113!17 = !{!18, !19}114!18 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !16, file: !1, line: 2, baseType: !14, size: 32)115!19 = !DIDerivedType(tag: DW_TAG_member, name: "b2", scope: !16, file: !1, line: 2, baseType: !20, size: 64)116!20 = !DIDerivedType(tag: DW_TAG_typedef, name: "__s1", file: !1, line: 1, baseType: !21)117!21 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 1, size: 64, elements: !22)118!22 = !{!23, !24}119!23 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !21, file: !1, line: 1, baseType: !14, size: 32)120!24 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !21, file: !1, line: 1, baseType: !25, size: 8, offset: 32)121!25 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)122!26 = !{!27, !28, !29, !30}123!27 = !DILocalVariable(name: "arg", arg: 1, scope: !11, file: !1, line: 4, type: !15)124!28 = !DILocalVariable(name: "r1", scope: !11, file: !1, line: 5, type: !4)125!29 = !DILocalVariable(name: "r2", scope: !11, file: !1, line: 6, type: !4)126!30 = !DILocalVariable(name: "r3", scope: !11, file: !1, line: 7, type: !4)127!31 = !DILocation(line: 0, scope: !11)128!32 = !DILocation(line: 5, column: 52, scope: !11)129!33 = !DILocation(line: 5, column: 17, scope: !11)130!34 = !DILocation(line: 6, column: 55, scope: !11)131!35 = !DILocation(line: 6, column: 17, scope: !11)132!36 = !DILocation(line: 7, column: 55, scope: !11)133!37 = !DILocation(line: 7, column: 17, scope: !11)134!38 = !DILocation(line: 9, column: 13, scope: !11)135!39 = !DILocation(line: 9, column: 18, scope: !11)136!40 = !DILocation(line: 9, column: 3, scope: !11)137