brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 7e2e8e6 Raw
79 lines · plain
1; RUN: opt -O2 %s | llvm-dis > %t12; RUN: llc -filetype=asm -o - %t1 | FileCheck %s3; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck %s4;5; Source code:6;   #define _(x) (__builtin_preserve_access_index(x))7;   struct s { int a; int b; };8;   int get_value(const ptr addr);9;   int test(struct s *arg) { return get_value(_(&arg[2].b)); }10; Compiler flag to generate IR:11;   clang -target bpf -S -O2 -g -emit-llvm -Xclang -disable-llvm-passes test.c12 13target triple = "bpf"14 15%struct.s = type { i32, i32 }16 17; Function Attrs: nounwind18define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !7 {19entry:20  call void @llvm.dbg.value(metadata ptr %arg, metadata !17, metadata !DIExpression()), !dbg !1821  %0 = tail call ptr @llvm.preserve.array.access.index.p0.ss.p0.ss(ptr elementtype(%struct.s) %arg, i32 0, i32 2), !dbg !19, !llvm.preserve.access.index !1122  %1 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.ss(ptr elementtype(%struct.s) %0, i32 1, i32 1), !dbg !19, !llvm.preserve.access.index !1223  %call = tail call i32 @get_value(ptr %1), !dbg !2024  ret i32 %call, !dbg !2125}26; CHECK-LABEL: test27; CHECK:       [[RELOC:.Ltmp[0-9]+]]28; CHECK:       r2 = 2029; CHECK:       r1 += r230; CHECK:       call get_value31; CHECK:       exit32;33; CHECK:      .section        .BTF.ext,"",@progbits34; CHECK:      .long   16                      # FieldReloc35; CHECK-NEXT: .long   20                      # Field reloc section string offset=2036; CHECK-NEXT: .long   137; CHECK-NEXT: .long   [[RELOC]]38; CHECK-NEXT: .long   239; CHECK-NEXT: .long   2640; CHECK-NEXT: .long   041 42declare dso_local i32 @get_value(ptr) local_unnamed_addr43 44; Function Attrs: nounwind readnone45declare ptr @llvm.preserve.array.access.index.p0.ss.p0.ss(ptr, i32 immarg, i32 immarg)46 47; Function Attrs: nounwind readnone48declare ptr @llvm.preserve.struct.access.index.p0.p0.ss(ptr, i32 immarg, i32 immarg)49 50; Function Attrs: nounwind readnone speculatable51declare void @llvm.dbg.value(metadata, metadata, metadata)52 53!llvm.dbg.cu = !{!0}54!llvm.module.flags = !{!3, !4, !5}55!llvm.ident = !{!6}56 57!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (trunk 365789)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)58!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")59!2 = !{}60!3 = !{i32 2, !"Dwarf Version", i32 4}61!4 = !{i32 2, !"Debug Info Version", i32 3}62!5 = !{i32 1, !"wchar_size", i32 4}63!6 = !{!"clang version 9.0.0 (trunk 365789)"}64!7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 4, type: !8, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)65!8 = !DISubroutineType(types: !9)66!9 = !{!10, !11}67!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)68!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)69!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", file: !1, line: 2, size: 64, elements: !13)70!13 = !{!14, !15}71!14 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !12, file: !1, line: 2, baseType: !10, size: 32)72!15 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !12, file: !1, line: 2, baseType: !10, size: 32, offset: 32)73!16 = !{!17}74!17 = !DILocalVariable(name: "arg", arg: 1, scope: !7, file: !1, line: 4, type: !11)75!18 = !DILocation(line: 0, scope: !7)76!19 = !DILocation(line: 4, column: 44, scope: !7)77!20 = !DILocation(line: 4, column: 34, scope: !7)78!21 = !DILocation(line: 4, column: 27, scope: !7)79