brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.3 KiB · f42e7e6 Raw
127 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 __v1 arr[4][4];8;   struct v3 { char c; int d[100]; };9;   #define _(x) (__builtin_preserve_access_index(x))10;   #define cast_to_arr(x) ((arr *)(x))11;   int get_value(const int *arg);12;   int test(struct v3 *arg) {13;     return get_value(_(&cast_to_arr(&arg->d[0])[0][2][3].b));14;   }15; Compilation flag:16;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c17 18target triple = "bpf"19 20%struct.v3 = type { i8, [100 x i32] }21%struct.v1 = type { i32, i32 }22 23; Function Attrs: nounwind24define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !24 {25entry:26  call void @llvm.dbg.value(metadata ptr %arg, metadata !34, metadata !DIExpression()), !dbg !3527  %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.v3) %arg, i32 1, i32 1), !dbg !36, !llvm.preserve.access.index !2828  %1 = tail call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype([100 x i32]) %0, i32 1, i32 0), !dbg !36, !llvm.preserve.access.index !1529  %2 = bitcast ptr %1 to ptr, !dbg !3630  %3 = tail call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype([4 x [4 x %struct.v1]]) %2, i32 0, i32 0), !dbg !36, !llvm.preserve.access.index !431  %4 = tail call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype([4 x [4 x %struct.v1]]) %3, i32 1, i32 2), !dbg !36, !llvm.preserve.access.index !532  %5 = tail call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype([4 x %struct.v1]) %4, i32 1, i32 3), !dbg !36, !llvm.preserve.access.index !1833  %6 = tail call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.v1) %5, i32 1, i32 1), !dbg !36, !llvm.preserve.access.index !834  %call = tail call i32 @get_value(ptr %6), !dbg !3735  ret i32 %call, !dbg !3836}37 38; CHECK:              r2 = 439; CHECK:              r1 += r240; CHECK:              r2 = 9241; CHECK:              r1 += r242; CHECK:              call get_value43 44; CHECK:              .long   1                       # BTF_KIND_STRUCT(id = [[TID1:[0-9]+]])45; CHECK:              .long   100                     # BTF_KIND_STRUCT(id = [[TID2:[0-9]+]])46 47; CHECK:              .ascii  "v3"                    # string offset=148; CHECK:              .ascii  ".text"                 # string offset=4649; CHECK:              .ascii  "0:1:0"                 # string offset=5250; CHECK:              .ascii  "v1"                    # string offset=10051; CHECK:              .ascii  "11:1"                  # string offset=10752 53; CHECK:              .long   16                      # FieldReloc54; CHECK-NEXT:         .long   46                      # Field reloc section string offset=4655; CHECK-NEXT:         .long   256; CHECK-NEXT:         .long   .Ltmp{{[0-9]+}}57; CHECK-NEXT:         .long   [[TID1]]58; CHECK-NEXT:         .long   5259; CHECK-NEXT:         .long   060; CHECK-NEXT:         .long   .Ltmp{{[0-9]+}}61; CHECK-NEXT:         .long   [[TID2]]62; CHECK-NEXT:         .long   10763; CHECK-NEXT:         .long   064 65declare dso_local i32 @get_value(ptr) local_unnamed_addr66 67; Function Attrs: nounwind readnone68declare ptr @llvm.preserve.struct.access.index.p0.p0(ptr, i32, i32)69 70; Function Attrs: nounwind readnone71declare ptr @llvm.preserve.array.access.index.p0.p0(ptr, i32, i32)72 73; Function Attrs: nounwind readnone74 75; Function Attrs: nounwind readnone76 77; Function Attrs: nounwind readnone78 79; Function Attrs: nounwind readnone80 81; Function Attrs: nounwind readnone speculatable willreturn82declare void @llvm.dbg.value(metadata, metadata, metadata)83 84!llvm.dbg.cu = !{!0}85!llvm.module.flags = !{!20, !21, !22}86!llvm.ident = !{!23}87 88!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)89!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/cast")90!2 = !{}91!3 = !{!4, !15, !5, !18}92!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)93!5 = !DIDerivedType(tag: DW_TAG_typedef, name: "arr", file: !1, line: 3, baseType: !6)94!6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 1024, elements: !13)95!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "__v1", file: !1, line: 2, baseType: !8)96!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v1", file: !1, line: 1, size: 64, elements: !9)97!9 = !{!10, !12}98!10 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !8, file: !1, line: 1, baseType: !11, size: 32)99!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)100!12 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !1, line: 1, baseType: !11, size: 32, offset: 32)101!13 = !{!14, !14}102!14 = !DISubrange(count: 4)103!15 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 3200, elements: !16)104!16 = !{!17}105!17 = !DISubrange(count: 100)106!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 256, elements: !19)107!19 = !{!14}108!20 = !{i32 2, !"Dwarf Version", i32 4}109!21 = !{i32 2, !"Debug Info Version", i32 3}110!22 = !{i32 1, !"wchar_size", i32 4}111!23 = !{!"clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)"}112!24 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 8, type: !25, scopeLine: 8, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !33)113!25 = !DISubroutineType(types: !26)114!26 = !{!11, !27}115!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64)116!28 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v3", file: !1, line: 4, size: 3232, elements: !29)117!29 = !{!30, !32}118!30 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !28, file: !1, line: 4, baseType: !31, size: 8)119!31 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)120!32 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !28, file: !1, line: 4, baseType: !15, size: 3200, offset: 32)121!33 = !{!34}122!34 = !DILocalVariable(name: "arg", arg: 1, scope: !24, file: !1, line: 8, type: !27)123!35 = !DILocation(line: 0, scope: !24)124!36 = !DILocation(line: 9, column: 20, scope: !24)125!37 = !DILocation(line: 9, column: 10, scope: !24)126!38 = !DILocation(line: 9, column: 3, scope: !24)127