1; RUN: llc -march=bpf < %s | FileCheck %s 2; 3; The IR is generated from a bpftrace script (https://github.com/iovisor/bpftrace/issues/1305) 4; and then slightly adapted for easy unit testing. 5; The llvm bugzilla link: https://bugs.llvm.org/show_bug.cgi?id=47591 6 7%printf_t = type { i64, i64 } 8 9define i64 @"kprobe:blk_update_request"(i8* %0) local_unnamed_addr section "s_kprobe:blk_update_request_1" { 10entry: 11 %"struct kernfs_node.parent" = alloca i64, align 8 12 %printf_args = alloca %printf_t, align 8 13 %"struct cgroup.kn" = alloca i64, align 8 14 %"struct cgroup_subsys_state.cgroup" = alloca i64, align 8 15 %"struct blkcg_gq.blkcg" = alloca i64, align 8 16 %"struct bio.bi_blkg" = alloca i64, align 8 17 %"struct request.bio" = alloca i64, align 8 18 %1 = getelementptr i8, i8* %0, i64 112 19 %2 = bitcast i8* %1 to i64* 20 %arg0 = load volatile i64, i64* %2, align 8 21 %3 = add i64 %arg0, 56 22 %4 = bitcast i64* %"struct request.bio" to i8* 23 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %4) 24 %probe_read = call i64 inttoptr (i64 4 to i64 (i64*, i32, i64)*)(i64* nonnull %"struct request.bio", i32 8, i64 %3) 25 %5 = load i64, i64* %"struct request.bio", align 8 26 call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %4) 27 %6 = add i64 %5, 72 28 %7 = bitcast i64* %"struct bio.bi_blkg" to i8* 29 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %7) 30 %probe_read1 = call i64 inttoptr (i64 5 to i64 (i64*, i32, i64)*)(i64* nonnull %"struct bio.bi_blkg", i32 8, i64 %6) 31 %8 = load i64, i64* %"struct bio.bi_blkg", align 8 32 call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %7) 33 %9 = add i64 %8, 40 34 %10 = bitcast i64* %"struct blkcg_gq.blkcg" to i8* 35 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %10) 36 %probe_read2 = call i64 inttoptr (i64 6 to i64 (i64*, i32, i64)*)(i64* nonnull %"struct blkcg_gq.blkcg", i32 8, i64 %9) 37 %11 = load i64, i64* %"struct blkcg_gq.blkcg", align 8 38 call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %10) 39 %12 = bitcast i64* %"struct cgroup_subsys_state.cgroup" to i8* 40 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %12) 41 %probe_read3 = call i64 inttoptr (i64 7 to i64 (i64*, i32, i64)*)(i64* nonnull %"struct cgroup_subsys_state.cgroup", i32 8, i64 %11) 42 %13 = load i64, i64* %"struct cgroup_subsys_state.cgroup", align 8 43 call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %12) 44 %14 = add i64 %13, 288 45 %15 = bitcast i64* %"struct cgroup.kn" to i8* 46 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %15) 47 %probe_read4 = call i64 inttoptr (i64 8 to i64 (i64*, i32, i64)*)(i64* nonnull %"struct cgroup.kn", i32 8, i64 %14) 48 %16 = load i64, i64* %"struct cgroup.kn", align 8 49 call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %15) 50 %17 = bitcast %printf_t* %printf_args to i8* 51 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %17) 52 %18 = add i64 %16, 8 53 %19 = bitcast i64* %"struct kernfs_node.parent" to i8* 54 %20 = getelementptr inbounds %printf_t, %printf_t* %printf_args, i64 0, i32 0 55 store i64 0, i64* %20, align 8 56 call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull %19) 57 58; CHECK: call 8 59; CHECK-NOT: r{{[0-9]+}} = 0 60; CHECK: [[REG3:r[0-9]+]] = *(u64 *)(r10 - 24) 61; CHECK: [[REG1:r[0-9]+]] = 0 62; CHECK: *(u64 *)(r10 - 24) = [[REG1]] 63 64 %probe_read5 = call i64 inttoptr (i64 9 to i64 (i64*, i32, i64)*)(i64* nonnull %"struct kernfs_node.parent", i32 8, i64 %18) 65 %21 = load i64, i64* %"struct kernfs_node.parent", align 8 66 call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %19) 67 %22 = getelementptr inbounds %printf_t, %printf_t* %printf_args, i64 0, i32 1 68 store i64 %21, i64* %22, align 8 69 %get_cpu_id = call i64 inttoptr (i64 18 to i64 ()*)() 70 %perf_event_output = call i64 inttoptr (i64 10 to i64 (i8*, i64, i64, %printf_t*, i64)*)(i8* %0, i64 2, i64 %get_cpu_id, %printf_t* nonnull %printf_args, i64 16) 71 call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull %17) 72 ret i64 0 73} 74 75; Function Attrs: argmemonly nounwind willreturn 76declare void @llvm.lifetime.start.p0i8(i64 immarg %0, i8* nocapture %1) #1 77 78; Function Attrs: argmemonly nounwind willreturn 79declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 80 81attributes #0 = { nounwind } 82attributes #1 = { argmemonly nounwind willreturn } 83