|
| 1 | +; RUN: llc -mtriple=bpf -mcpu=v2 < %s | FileCheck -check-prefixes=CHECK %s |
| 2 | + |
| 3 | +; Test for machine register liveness update bug in |
| 4 | +; BPFMISimplifyPatchable::processDstReg. |
| 5 | +; |
| 6 | +; Generated from the following source code: |
| 7 | +; struct t { |
| 8 | +; unsigned long a; |
| 9 | +; } __attribute__((preserve_access_index)); |
| 10 | +; |
| 11 | +; void foo(volatile struct t *t, volatile unsigned long *p) { |
| 12 | +; *p = t->a; |
| 13 | +; *p = t->a; |
| 14 | +; } |
| 15 | +; |
| 16 | +; Using the following command: |
| 17 | +; clang -g -O2 -S -emit-llvm --target=bpf t.c -o t.ll |
| 18 | + |
| 19 | +@"llvm.t:0:0$0:0" = external global i64, !llvm.preserve.access.index !0 #0 |
| 20 | + |
| 21 | +; Function Attrs: nofree nounwind |
| 22 | +define dso_local void @foo(ptr noundef %t, ptr noundef %p) local_unnamed_addr #1 !dbg !12 { |
| 23 | +entry: |
| 24 | + call void @llvm.dbg.value(metadata ptr %t, metadata !20, metadata !DIExpression()), !dbg !22 |
| 25 | + call void @llvm.dbg.value(metadata ptr %p, metadata !21, metadata !DIExpression()), !dbg !22 |
| 26 | + %0 = load i64, ptr @"llvm.t:0:0$0:0", align 8 |
| 27 | + %1 = getelementptr i8, ptr %t, i64 %0 |
| 28 | + %2 = tail call ptr @llvm.bpf.passthrough.p0.p0(i32 0, ptr %1) |
| 29 | + %3 = load volatile i64, ptr %2, align 8, !dbg !23, !tbaa !24 |
| 30 | + store volatile i64 %3, ptr %p, align 8, !dbg !29, !tbaa !30 |
| 31 | + %4 = load i64, ptr @"llvm.t:0:0$0:0", align 8 |
| 32 | + %5 = getelementptr i8, ptr %t, i64 %4 |
| 33 | + %6 = tail call ptr @llvm.bpf.passthrough.p0.p0(i32 1, ptr %5) |
| 34 | + %7 = load volatile i64, ptr %6, align 8, !dbg !31, !tbaa !24 |
| 35 | + store volatile i64 %7, ptr %p, align 8, !dbg !32, !tbaa !30 |
| 36 | + ret void, !dbg !33 |
| 37 | +} |
| 38 | + |
| 39 | +; CHECK: foo: |
| 40 | +; CHECK: prologue_end |
| 41 | +; CHECK-NEXT: .Ltmp[[LABEL1:.*]]: |
| 42 | +; CHECK-NEXT: .Ltmp |
| 43 | +; CHECK-NEXT: r[[#A:]] = *(u64 *)(r1 + 0) |
| 44 | +; CHECK-NEXT: .loc |
| 45 | +; CHECK-NEXT: .Ltmp |
| 46 | +; CHECK-NEXT: *(u64 *)(r2 + 0) = r[[#A]] |
| 47 | +; CHECK-NEXT: .loc |
| 48 | +; CHECK-NEXT: .Ltmp[[LABEL2:.*]]: |
| 49 | +; CHECK-NEXT: .Ltmp |
| 50 | +; CHECK-NEXT: r[[#B:]] = *(u64 *)(r1 + 0) |
| 51 | +; CHECK-NEXT: .Ltmp |
| 52 | +; CHECK-NEXT: .Ltmp |
| 53 | +; CHECK-NEXT: .loc |
| 54 | +; CHECK-NEXT: .Ltmp |
| 55 | +; CHECK-NEXT: *(u64 *)(r2 + 0) = r[[#B]] |
| 56 | + |
| 57 | +; CHECK: .section .BTF |
| 58 | +; CHECK: .long [[STR_T:.*]] # BTF_KIND_STRUCT(id = [[ID:.*]]) |
| 59 | + |
| 60 | +; CHECK: .byte 116 # string offset=[[STR_T]] |
| 61 | +; CHECK: .ascii "0:0" # string offset=[[STR_A:.*]] |
| 62 | + |
| 63 | +; CHECK: # FieldReloc |
| 64 | +; CHECK: .long .Ltmp[[LABEL1]] |
| 65 | +; CHECK-NEXT: .long [[ID]] |
| 66 | +; CHECK-NEXT: .long [[STR_A]] |
| 67 | +; CHECK-NEXT: .long 0 |
| 68 | +; CHECK: .long .Ltmp[[LABEL2]] |
| 69 | +; CHECK-NEXT: .long [[ID]] |
| 70 | +; CHECK-NEXT: .long [[STR_A]] |
| 71 | +; CHECK-NEXT: .long 0 |
| 72 | + |
| 73 | +; Function Attrs: nofree nosync nounwind memory(none) |
| 74 | +declare ptr @llvm.bpf.passthrough.p0.p0(i32, ptr) #2 |
| 75 | + |
| 76 | +; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) |
| 77 | +declare void @llvm.dbg.value(metadata, metadata, metadata) #3 |
| 78 | + |
| 79 | +attributes #0 = { "btf_ama" } |
| 80 | +attributes #1 = { nofree nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } |
| 81 | +attributes #2 = { nofree nosync nounwind memory(none) } |
| 82 | +attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
| 83 | + |
| 84 | +!llvm.dbg.cu = !{!5} |
| 85 | +!llvm.module.flags = !{!6, !7, !8, !9, !10} |
| 86 | +!llvm.ident = !{!11} |
| 87 | + |
| 88 | +!0 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t", file: !1, line: 1, size: 64, elements: !2) |
| 89 | +!1 = !DIFile(filename: "some.file", directory: "/some/dir", checksumkind: CSK_MD5, checksum: "a149cfaf65a83125e7f2b2f47e5c7287") |
| 90 | +!2 = !{!3} |
| 91 | +!3 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !0, file: !1, line: 2, baseType: !4, size: 64) |
| 92 | +!4 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) |
| 93 | +!5 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 18.0.0 (/home/eddy/work/llvm-project/clang 3810f2eb4382d5e2090ce5cd47f45379cb453c35)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) |
| 94 | +!6 = !{i32 7, !"Dwarf Version", i32 5} |
| 95 | +!7 = !{i32 2, !"Debug Info Version", i32 3} |
| 96 | +!8 = !{i32 1, !"wchar_size", i32 4} |
| 97 | +!9 = !{i32 7, !"frame-pointer", i32 2} |
| 98 | +!10 = !{i32 7, !"debug-info-assignment-tracking", i1 true} |
| 99 | +!11 = !{!"clang version 18.0.0 (/home/eddy/work/llvm-project/clang 3810f2eb4382d5e2090ce5cd47f45379cb453c35)"} |
| 100 | +!12 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !13, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !5, retainedNodes: !19) |
| 101 | +!13 = !DISubroutineType(types: !14) |
| 102 | +!14 = !{null, !15, !17} |
| 103 | +!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64) |
| 104 | +!16 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !0) |
| 105 | +!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64) |
| 106 | +!18 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !4) |
| 107 | +!19 = !{!20, !21} |
| 108 | +!20 = !DILocalVariable(name: "t", arg: 1, scope: !12, file: !1, line: 4, type: !15) |
| 109 | +!21 = !DILocalVariable(name: "p", arg: 2, scope: !12, file: !1, line: 4, type: !17) |
| 110 | +!22 = !DILocation(line: 0, scope: !12) |
| 111 | +!23 = !DILocation(line: 5, column: 11, scope: !12) |
| 112 | +!24 = !{!25, !26, i64 0} |
| 113 | +!25 = !{!"t", !26, i64 0} |
| 114 | +!26 = !{!"long", !27, i64 0} |
| 115 | +!27 = !{!"omnipotent char", !28, i64 0} |
| 116 | +!28 = !{!"Simple C/C++ TBAA"} |
| 117 | +!29 = !DILocation(line: 5, column: 6, scope: !12) |
| 118 | +!30 = !{!26, !26, i64 0} |
| 119 | +!31 = !DILocation(line: 6, column: 11, scope: !12) |
| 120 | +!32 = !DILocation(line: 6, column: 6, scope: !12) |
| 121 | +!33 = !DILocation(line: 7, column: 1, scope: !12) |
0 commit comments