125 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 t1 {6; int c;7; };8; struct s1 {9; struct t1 b;10; };11; struct r1 {12; struct s1 a;13; };14; #define _(x) __builtin_preserve_access_index(x)15; void test1(ptr p1, ptr p2, ptr p3);16; void test(struct r1 *arg) {17; struct s1 *ps = _(&arg->a);18; struct t1 *pt = _(&arg->a.b);19; int *pi = _(&arg->a.b.c);20; test1(ps, pt, pi);21; }22; Compilation flag:23; clang -target bpf -O2 -g -S -emit-llvm -Xclang -disable-llvm-passes test.c24 25target triple = "bpf"26 27%struct.r1 = type { %struct.s1 }28%struct.s1 = type { %struct.t1 }29%struct.t1 = type { i32 }30 31; Function Attrs: nounwind32define dso_local void @test(ptr %arg) local_unnamed_addr !dbg !7 {33entry:34 call void @llvm.dbg.value(metadata ptr %arg, metadata !22, metadata !DIExpression()), !dbg !2935 %0 = tail call ptr @llvm.preserve.struct.access.index.p0.s1s.p0.r1s(ptr elementtype(%struct.r1) %arg, i32 0, i32 0), !dbg !30, !llvm.preserve.access.index !1136 call void @llvm.dbg.value(metadata ptr %0, metadata !23, metadata !DIExpression()), !dbg !2937 %1 = tail call ptr @llvm.preserve.struct.access.index.p0.t1s.p0.s1s(ptr elementtype(%struct.s1) %0, i32 0, i32 0), !dbg !31, !llvm.preserve.access.index !1438 call void @llvm.dbg.value(metadata ptr %1, metadata !25, metadata !DIExpression()), !dbg !2939 %2 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.t1s(ptr elementtype(%struct.t1) %1, i32 0, i32 0), !dbg !32, !llvm.preserve.access.index !1740 call void @llvm.dbg.value(metadata ptr %2, metadata !27, metadata !DIExpression()), !dbg !2941 tail call void @test1(ptr %0, ptr %1, ptr %2), !dbg !3642 ret void, !dbg !3743}44 45; CHECK: .long 1 # BTF_KIND_STRUCT(id = 2)46 47; CHECK: .ascii "r1" # string offset=148; CHECK: .ascii ".text" # string offset=2949; CHECK: .ascii "0:0" # string offset=7250; CHECK: .ascii "0:0:0" # string offset=7651; CHECK: .ascii "0:0:0:0" # string offset=8252 53; CHECK: .long 16 # FieldReloc54; CHECK-NEXT: .long 29 # Field reloc section string offset=2955; CHECK-NEXT: .long 356; CHECK-NEXT: .long .Ltmp{{[0-9]+}}57; CHECK-NEXT: .long 258; CHECK-NEXT: .long 7259; CHECK-NEXT: .long 060; CHECK-NEXT: .long .Ltmp{{[0-9]+}}61; CHECK-NEXT: .long 262; CHECK-NEXT: .long 7663; CHECK-NEXT: .long 064; CHECK-NEXT: .long .Ltmp{{[0-9]+}}65; CHECK-NEXT: .long 266; CHECK-NEXT: .long 8267; CHECK-NEXT: .long 068 69; Function Attrs: nounwind readnone70declare ptr @llvm.preserve.struct.access.index.p0.s1s.p0.r1s(ptr, i32, i32)71 72; Function Attrs: nounwind readnone73declare ptr @llvm.preserve.struct.access.index.p0.t1s.p0.s1s(ptr, i32, i32)74 75; Function Attrs: nounwind readnone76declare ptr @llvm.preserve.struct.access.index.p0.p0.t1s(ptr, i32, i32)77 78declare dso_local void @test1(ptr, ptr, ptr) local_unnamed_addr79 80; Function Attrs: nounwind readnone speculatable willreturn81declare void @llvm.dbg.value(metadata, metadata, metadata)82 83!llvm.dbg.cu = !{!0}84!llvm.module.flags = !{!3, !4, !5}85!llvm.ident = !{!6}86 87!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 42b3328a2368b38fba6bdb0c616fe6c5520e3bc5)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)88!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")89!2 = !{}90!3 = !{i32 2, !"Dwarf Version", i32 4}91!4 = !{i32 2, !"Debug Info Version", i32 3}92!5 = !{i32 1, !"wchar_size", i32 4}93!6 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 42b3328a2368b38fba6bdb0c616fe6c5520e3bc5)"}94!7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 12, type: !8, scopeLine: 12, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !21)95!8 = !DISubroutineType(types: !9)96!9 = !{null, !10}97!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)98!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "r1", file: !1, line: 7, size: 32, elements: !12)99!12 = !{!13}100!13 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !11, file: !1, line: 8, baseType: !14, size: 32)101!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1", file: !1, line: 4, size: 32, elements: !15)102!15 = !{!16}103!16 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !14, file: !1, line: 5, baseType: !17, size: 32)104!17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !1, line: 1, size: 32, elements: !18)105!18 = !{!19}106!19 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !17, file: !1, line: 2, baseType: !20, size: 32)107!20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)108!21 = !{!22, !23, !25, !27}109!22 = !DILocalVariable(name: "arg", arg: 1, scope: !7, file: !1, line: 12, type: !10)110!23 = !DILocalVariable(name: "ps", scope: !7, file: !1, line: 13, type: !24)111!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)112!25 = !DILocalVariable(name: "pt", scope: !7, file: !1, line: 14, type: !26)113!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64)114!27 = !DILocalVariable(name: "pi", scope: !7, file: !1, line: 15, type: !28)115!28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64)116!29 = !DILocation(line: 0, scope: !7)117!30 = !DILocation(line: 13, column: 19, scope: !7)118!31 = !DILocation(line: 14, column: 19, scope: !7)119!32 = !DILocation(line: 15, column: 13, scope: !7)120!33 = !DILocation(line: 16, column: 9, scope: !7)121!34 = !DILocation(line: 16, column: 13, scope: !7)122!35 = !DILocation(line: 16, column: 17, scope: !7)123!36 = !DILocation(line: 16, column: 3, scope: !7)124!37 = !DILocation(line: 17, column: 1, scope: !7)125