77 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; const ptr test(struct s *arg) { return _(&arg->b); }9; Compiler flag to generate IR:10; clang -target bpf -S -O2 -g -emit-llvm -Xclang -disable-llvm-passes test.c11 12target triple = "bpf"13 14%struct.s = type { i32, i32 }15 16; Function Attrs: nounwind readnone17define dso_local ptr @test(ptr readnone %arg) local_unnamed_addr !dbg !7 {18entry:19 call void @llvm.dbg.value(metadata ptr %arg, metadata !19, metadata !DIExpression()), !dbg !2020 %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.ss(ptr elementtype(%struct.s) %arg, i32 1, i32 1), !dbg !21, !llvm.preserve.access.index !1321 ret ptr %0, !dbg !2222}23 24; CHECK-LABEL: test25; CHECK: r0 = r126; CHECK: r1 = 427; CHECK: r0 += r128; CHECK: exit29;30; CHECK: .long 1 # BTF_KIND_STRUCT(id = 2)31;32; CHECK: .byte 115 # string offset=133; CHECK: .ascii ".text" # string offset=2034; CHECK: .ascii "0:1" # string offset=6335;36; CHECK: .long 16 # FieldReloc37; CHECK-NEXT: .long 20 # Field reloc section string offset=2038; CHECK-NEXT: .long 139; CHECK-NEXT: .long .Ltmp{{[0-9]+}}40; CHECK-NEXT: .long 241; CHECK-NEXT: .long 6342; CHECK-NEXT: .long 043 44; Function Attrs: nounwind readnone45declare ptr @llvm.preserve.struct.access.index.p0.p0.ss(ptr, i32, i32)46 47; Function Attrs: nounwind readnone speculatable willreturn48declare void @llvm.dbg.value(metadata, metadata, metadata)49 50!llvm.dbg.cu = !{!0}51!llvm.module.flags = !{!3, !4, !5}52!llvm.ident = !{!6}53 54!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 (https://github.com/llvm/llvm-project.git 6e353b4df3aa452ed4741a5e5caea02b1a876d8c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)55!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")56!2 = !{}57!3 = !{i32 2, !"Dwarf Version", i32 4}58!4 = !{i32 2, !"Debug Info Version", i32 3}59!5 = !{i32 1, !"wchar_size", i32 4}60!6 = !{!"clang version 10.0.0 (https://github.com/llvm/llvm-project.git 6e353b4df3aa452ed4741a5e5caea02b1a876d8c)"}61!7 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, isDefinition: true, isOptimized: true, unit: !0, retainedNodes: !18)62!8 = !DISubroutineType(types: !9)63!9 = !{!10, !12}64!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)65!11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)66!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)67!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", file: !1, line: 2, size: 64, elements: !14)68!14 = !{!15, !17}69!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !1, line: 2, baseType: !16, size: 32)70!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)71!17 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !1, line: 2, baseType: !16, size: 32, offset: 32)72!18 = !{!19}73!19 = !DILocalVariable(name: "arg", arg: 1, scope: !7, file: !1, line: 3, type: !12)74!20 = !DILocation(line: 0, scope: !7)75!21 = !DILocation(line: 3, column: 42, scope: !7)76!22 = !DILocation(line: 3, column: 35, scope: !7)77