brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.7 KiB · 2c8a0c4 Raw
105 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; RUN: opt -passes='default<O2>' %s | llvm-dis > %t15; RUN: llc -filetype=asm -o - %t1 | FileCheck %s6; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck %s7; Source code:8;   struct t {9;     int a;10;   } __attribute__((preserve_access_index));11;   int foo(ptr);12;   int test(struct t *arg) {13;       long param[1];14;       param[0] = (long)&arg->a;15;       return foo(param);16;   }17; Compiler flag to generate IR:18;   clang -target bpf -S -O2 -g -emit-llvm -Xclang -disable-llvm-passes test.c19 20target triple = "bpf"21 22%struct.t = type { i32 }23 24; Function Attrs: nounwind25define dso_local i32 @test(ptr %arg) local_unnamed_addr !dbg !14 {26entry:27  %param = alloca [1 x i64], align 828  call void @llvm.dbg.value(metadata ptr %arg, metadata !22, metadata !DIExpression()), !dbg !2729  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %param), !dbg !2830  call void @llvm.dbg.declare(metadata ptr %param, metadata !23, metadata !DIExpression()), !dbg !2931  %0 = tail call ptr @llvm.preserve.struct.access.index.p0.p0.ts(ptr elementtype(%struct.t) %arg, i32 0, i32 0), !dbg !30, !llvm.preserve.access.index !1832  %1 = ptrtoint ptr %0 to i64, !dbg !3133  store i64 %1, ptr %param, align 8, !dbg !33, !tbaa !3434  %call = call i32 @foo(ptr nonnull %param), !dbg !3835  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %param), !dbg !3936  ret i32 %call, !dbg !4037}38 39; CHECK:  r[[OFFSET:[0-9]+]] = 040; CHECK:  r1 += r[[OFFSET]]41; CHECK:  *(u64 *)(r10 - 8) = r142 43; Function Attrs: nounwind readnone speculatable44declare void @llvm.dbg.declare(metadata, metadata, metadata)45 46; Function Attrs: argmemonly nounwind47declare void @llvm.lifetime.start.p0(i64, ptr nocapture)48 49; Function Attrs: nounwind readnone50declare ptr @llvm.preserve.struct.access.index.p0.p0.ts(ptr, i32, i32)51 52declare !dbg !5 dso_local i32 @foo(ptr) local_unnamed_addr53 54; Function Attrs: argmemonly nounwind55declare void @llvm.lifetime.end.p0(i64, ptr nocapture)56 57; Function Attrs: nounwind readnone speculatable58declare void @llvm.dbg.value(metadata, metadata, metadata)59 60!llvm.dbg.cu = !{!0}61!llvm.module.flags = !{!10, !11, !12}62!llvm.ident = !{!13}63 64!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 4f995959a05ae94cc4f9cc80035f7e4b3ecd2d88)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)65!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/core")66!2 = !{}67!3 = !{!4, !5}68!4 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)69!5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !6, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)70!6 = !DISubroutineType(types: !7)71!7 = !{!8, !9}72!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)73!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)74!10 = !{i32 7, !"Dwarf Version", i32 4}75!11 = !{i32 2, !"Debug Info Version", i32 3}76!12 = !{i32 1, !"wchar_size", i32 4}77!13 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 4f995959a05ae94cc4f9cc80035f7e4b3ecd2d88)"}78!14 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 5, type: !15, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !21)79!15 = !DISubroutineType(types: !16)80!16 = !{!8, !17}81!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64)82!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t", file: !1, line: 1, size: 32, elements: !19)83!19 = !{!20}84!20 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !18, file: !1, line: 2, baseType: !8, size: 32)85!21 = !{!22, !23}86!22 = !DILocalVariable(name: "arg", arg: 1, scope: !14, file: !1, line: 5, type: !17)87!23 = !DILocalVariable(name: "param", scope: !14, file: !1, line: 6, type: !24)88!24 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 64, elements: !25)89!25 = !{!26}90!26 = !DISubrange(count: 1)91!27 = !DILocation(line: 0, scope: !14)92!28 = !DILocation(line: 6, column: 5, scope: !14)93!29 = !DILocation(line: 6, column: 10, scope: !14)94!30 = !DILocation(line: 7, column: 28, scope: !14)95!31 = !DILocation(line: 7, column: 16, scope: !14)96!32 = !DILocation(line: 7, column: 5, scope: !14)97!33 = !DILocation(line: 7, column: 14, scope: !14)98!34 = !{!35, !35, i64 0}99!35 = !{!"long", !36, i64 0}100!36 = !{!"omnipotent char", !37, i64 0}101!37 = !{!"Simple C/C++ TBAA"}102!38 = !DILocation(line: 8, column: 12, scope: !14)103!39 = !DILocation(line: 9, column: 1, scope: !14)104!40 = !DILocation(line: 8, column: 5, scope: !14)105