brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · e5ef549 Raw
115 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s3; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck -check-prefixes=CHECK %s4; Source code:5;   struct v1 { int a; int b; };6;   typedef struct v1 __v1;7;   typedef int __int;8;   struct v3 { char c; __int d[40]; };9;   typedef struct v3 __v3;10;   #define _(x) (__builtin_preserve_access_index(x))11;   #define cast_to_v1(x) ((__v1 *)(x))12;   int get_value(const int *arg);13;   int test(__v3 *arg) {14;     return get_value(_(&cast_to_v1(&arg->d[4])->b));15;   }16; Compilation flag:17;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c18 19target triple = "bpf"20 21%struct.v3 = type { i8, [40 x i32] }22%struct.v1 = type { i32, i32 }23 24; Function Attrs: nounwind25define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !19 {26entry:27  call void @llvm.dbg.value(metadata ptr %arg, metadata !30, metadata !DIExpression()), !dbg !3128  %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.v3) %arg, i32 1, i32 1), !dbg !32, !llvm.preserve.access.index !2429  %1 = tail call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype([40 x i32]) %0, i32 1, i32 4), !dbg !32, !llvm.preserve.access.index !1130  %2 = bitcast ptr %1 to ptr, !dbg !3231  %3 = tail call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.v1) %2, i32 1, i32 1), !dbg !32, !llvm.preserve.access.index !632  %call = tail call i32 @get_value(ptr %3), !dbg !3333  ret i32 %call, !dbg !3434}35 36; CHECK:             r2 = 2037; CHECK:             r1 += r238; CHECK:             r2 = 439; CHECK:             r1 += r240; CHECK:             call get_value41 42; CHECK:             .long   6                       # BTF_KIND_STRUCT(id = [[TID1:[0-9]+]])43; CHECK:             .long   111                     # BTF_KIND_STRUCT(id = [[TID2:[0-9]+]])44 45; CHECK:             .ascii  "v3"                    # string offset=646; CHECK:             .ascii  ".text"                 # string offset=5747; CHECK:             .ascii  "0:1:4"                 # string offset=6348; CHECK:             .ascii  "v1"                    # string offset=11149; CHECK:             .ascii  "0:1"                   # string offset=11850 51; CHECK:             .long   16                      # FieldReloc52; CHECK-NEXT:        .long   57                      # Field reloc section string offset=5753; CHECK-NEXT:        .long   254; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}55; CHECK-NEXT:        .long   [[TID1]]56; CHECK-NEXT:        .long   6357; CHECK-NEXT:        .long   058; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}59; CHECK-NEXT:        .long   [[TID2]]60; CHECK-NEXT:        .long   11861; CHECK-NEXT:        .long   062 63declare dso_local i32 @get_value(ptr) local_unnamed_addr64 65; Function Attrs: nounwind readnone66declare ptr @llvm.preserve.struct.access.index.p0.p0(ptr, i32, i32)67 68; Function Attrs: nounwind readnone69declare ptr @llvm.preserve.array.access.index.p0.p0(ptr, i32, i32)70 71; Function Attrs: nounwind readnone72 73; Function Attrs: nounwind readnone speculatable willreturn74declare void @llvm.dbg.value(metadata, metadata, metadata)75 76!llvm.dbg.cu = !{!0}77!llvm.module.flags = !{!15, !16, !17}78!llvm.ident = !{!18}79 80!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)81!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/cast")82!2 = !{}83!3 = !{!4, !11}84!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)85!5 = !DIDerivedType(tag: DW_TAG_typedef, name: "__v1", file: !1, line: 2, baseType: !6)86!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v1", file: !1, line: 1, size: 64, elements: !7)87!7 = !{!8, !10}88!8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !1, line: 1, baseType: !9, size: 32)89!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)90!10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !1, line: 1, baseType: !9, size: 32, offset: 32)91!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 1280, elements: !13)92!12 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int", file: !1, line: 3, baseType: !9)93!13 = !{!14}94!14 = !DISubrange(count: 40)95!15 = !{i32 2, !"Dwarf Version", i32 4}96!16 = !{i32 2, !"Debug Info Version", i32 3}97!17 = !{i32 1, !"wchar_size", i32 4}98!18 = !{!"clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)"}99!19 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 9, type: !20, scopeLine: 9, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !29)100!20 = !DISubroutineType(types: !21)101!21 = !{!9, !22}102!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64)103!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "__v3", file: !1, line: 5, baseType: !24)104!24 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v3", file: !1, line: 4, size: 1312, elements: !25)105!25 = !{!26, !28}106!26 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !24, file: !1, line: 4, baseType: !27, size: 8)107!27 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)108!28 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !24, file: !1, line: 4, baseType: !11, size: 1280, offset: 32)109!29 = !{!30}110!30 = !DILocalVariable(name: "arg", arg: 1, scope: !19, file: !1, line: 9, type: !22)111!31 = !DILocation(line: 0, scope: !19)112!32 = !DILocation(line: 10, column: 20, scope: !19)113!33 = !DILocation(line: 10, column: 10, scope: !19)114!34 = !DILocation(line: 10, column: 3, scope: !19)115