1 ; RUN: llc -mtriple=bpf -mcpu=v2 < %s | FileCheck -check-prefixes=CHECK %s
3 ; Test for machine register liveness update bug in
4 ; BPFMISimplifyPatchable::processDstReg.
6 ; Generated from the following source code:
9 ; } __attribute__((preserve_access_index));
11 ; void foo(volatile struct t *t, volatile unsigned long *p) {
16 ; Using the following command:
17 ; clang -g -O2 -S -emit-llvm --target=bpf t.c -o t.ll
19 @"llvm.t:0:0$0:0" = external global i64, !llvm.preserve.access.index !0 #0
21 ; Function Attrs: nofree nounwind
22 define dso_local void @foo(ptr noundef %t, ptr noundef %p) local_unnamed_addr #1 !dbg !12 {
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
41 ; CHECK-NEXT: .Ltmp[[LABEL1:.*]]:
43 ; CHECK-NEXT: r[[#A:]] = *(u64 *)(r1 + 0)
46 ; CHECK-NEXT: *(u64 *)(r2 + 0) = r[[#A]]
48 ; CHECK-NEXT: .Ltmp[[LABEL2:.*]]:
50 ; CHECK-NEXT: r[[#B:]] = *(u64 *)(r1 + 0)
55 ; CHECK-NEXT: *(u64 *)(r2 + 0) = r[[#B]]
57 ; CHECK: .section .BTF
58 ; CHECK: .long [[STR_T:.*]] # BTF_KIND_STRUCT(id = [[ID:.*]])
60 ; CHECK: .byte 116 # string offset=[[STR_T]]
61 ; CHECK: .ascii "0:0" # string offset=[[STR_A:.*]]
64 ; CHECK: .long .Ltmp[[LABEL1]]
65 ; CHECK-NEXT: .long [[ID]]
66 ; CHECK-NEXT: .long [[STR_A]]
68 ; CHECK: .long .Ltmp[[LABEL2]]
69 ; CHECK-NEXT: .long [[ID]]
70 ; CHECK-NEXT: .long [[STR_A]]
73 ; Function Attrs: nofree nosync nounwind memory(none)
74 declare ptr @llvm.bpf.passthrough.p0.p0(i32, ptr) #2
76 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
77 declare void @llvm.dbg.value(metadata, metadata, metadata) #3
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) }
85 !llvm.module.flags = !{!6, !7, !8, !9, !10}
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")
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)
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)