brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.7 KiB · 7730ee3 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;   struct v2 { int c; int d; };8;   typedef struct v2 __v2;9;   struct v3 { char c; volatile const __v2 d; };10;   typedef struct v3 __v3;11;   #define _(x) (__builtin_preserve_access_index(x))12;   #define cast_to_v1(x) ((__v1 *)(x))13;   int get_value(const int *arg);14;   int test(__v3 *arg) {15;     return get_value(_(&cast_to_v1(&arg->d)->b));16;   }17; Compilation flag:18;   clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c19 20target triple = "bpf"21 22%struct.v3 = type { i8, %struct.v2 }23%struct.v2 = type { i32, i32 }24%struct.v1 = type { i32, i32 }25 26; Function Attrs: nounwind27define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !15 {28entry:29  call void @llvm.dbg.value(metadata ptr %arg, metadata !33, metadata !DIExpression()), !dbg !3430  %0 = tail call ptr @llvm.preserve.struct.access.index.p0.v2s.p0.v3s(ptr elementtype(%struct.v3) %arg, i32 1, i32 1), !dbg !35, !llvm.preserve.access.index !2031  %1 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.v1s(ptr elementtype(%struct.v1) %0, i32 1, i32 1), !dbg !35, !llvm.preserve.access.index !632  %call = tail call i32 @get_value(ptr %1), !dbg !3633  ret i32 %call, !dbg !3734}35 36; CHECK:             r2 = 437; 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   91                      # BTF_KIND_STRUCT(id = [[TID2:[0-9]+]])44 45; CHECK:             .ascii  "v3"                    # string offset=646; CHECK:             .ascii  ".text"                 # string offset=3947; CHECK:             .ascii  "0:1"                   # string offset=4548; CHECK:             .ascii  "v1"                    # string offset=9149 50; CHECK:             .long   16                      # FieldReloc51; CHECK-NEXT:        .long   39                      # Field reloc section string offset=3952; CHECK-NEXT:        .long   253; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}54; CHECK-NEXT:        .long   [[TID1]]55; CHECK-NEXT:        .long   4556; CHECK-NEXT:        .long   057; CHECK-NEXT:        .long   .Ltmp{{[0-9]+}}58; CHECK-NEXT:        .long   [[TID2]]59; CHECK-NEXT:        .long   4560; CHECK-NEXT:        .long   061 62declare dso_local i32 @get_value(ptr) local_unnamed_addr63 64; Function Attrs: nounwind readnone65declare ptr @llvm.preserve.struct.access.index.p0.v2s.p0.v3s(ptr, i32, i32)66 67; Function Attrs: nounwind readnone68declare ptr @llvm.preserve.struct.access.index.p0.p0.v1s(ptr, i32, i32)69 70; Function Attrs: nounwind readnone speculatable willreturn71declare void @llvm.dbg.value(metadata, metadata, metadata)72 73!llvm.dbg.cu = !{!0}74!llvm.module.flags = !{!11, !12, !13}75!llvm.ident = !{!14}76 77!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)78!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/cast")79!2 = !{}80!3 = !{!4}81!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)82!5 = !DIDerivedType(tag: DW_TAG_typedef, name: "__v1", file: !1, line: 2, baseType: !6)83!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v1", file: !1, line: 1, size: 64, elements: !7)84!7 = !{!8, !10}85!8 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !6, file: !1, line: 1, baseType: !9, size: 32)86!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)87!10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !6, file: !1, line: 1, baseType: !9, size: 32, offset: 32)88!11 = !{i32 2, !"Dwarf Version", i32 4}89!12 = !{i32 2, !"Debug Info Version", i32 3}90!13 = !{i32 1, !"wchar_size", i32 4}91!14 = !{!"clang version 10.0.0 (trunk 367256) (llvm/trunk 367266)"}92!15 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 10, type: !16, scopeLine: 10, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !32)93!16 = !DISubroutineType(types: !17)94!17 = !{!9, !18}95!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)96!19 = !DIDerivedType(tag: DW_TAG_typedef, name: "__v3", file: !1, line: 6, baseType: !20)97!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v3", file: !1, line: 5, size: 96, elements: !21)98!21 = !{!22, !24}99!22 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !20, file: !1, line: 5, baseType: !23, size: 8)100!23 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)101!24 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !20, file: !1, line: 5, baseType: !25, size: 64, offset: 32)102!25 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !26)103!26 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !27)104!27 = !DIDerivedType(tag: DW_TAG_typedef, name: "__v2", file: !1, line: 4, baseType: !28)105!28 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v2", file: !1, line: 3, size: 64, elements: !29)106!29 = !{!30, !31}107!30 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !28, file: !1, line: 3, baseType: !9, size: 32)108!31 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !28, file: !1, line: 3, baseType: !9, size: 32, offset: 32)109!32 = !{!33}110!33 = !DILocalVariable(name: "arg", arg: 1, scope: !15, file: !1, line: 10, type: !18)111!34 = !DILocation(line: 0, scope: !15)112!35 = !DILocation(line: 11, column: 20, scope: !15)113!36 = !DILocation(line: 11, column: 10, scope: !15)114!37 = !DILocation(line: 11, column: 3, scope: !15)115