1 ; RUN: llvm-profdata merge %S/Inputs/memop_size_annotation.proftext -o %t.profdata
2 ; RUN: opt < %s -pgo-instr-use -memop-max-annotations=9 -pgo-test-profile-file=%t.profdata -pgo-memop-optimize-memcmp-bcmp -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION9
3 ; RUN: opt < %s -passes=pgo-instr-use -memop-max-annotations=9 -pgo-test-profile-file=%t.profdata -pgo-memop-optimize-memcmp-bcmp -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION9
4 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-memop-optimize-memcmp-bcmp -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION4
5 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-memop-optimize-memcmp-bcmp -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION4
7 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-unknown-linux-gnu"
10 define void @foo(i8* %dst, i8* %src, i32* %a, i32 %n) {
15 %i.0 = phi i32 [ 0, %entry ], [ %inc5, %for.inc4 ]
16 %cmp = icmp slt i32 %i.0, %n
17 br i1 %cmp, label %for.body, label %for.end6
23 %j.0 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]
24 %idx.ext = sext i32 %i.0 to i64
25 %add.ptr = getelementptr inbounds i32, i32* %a, i64 %idx.ext
26 %0 = load i32, i32* %add.ptr, align 4
27 %cmp2 = icmp slt i32 %j.0, %0
28 br i1 %cmp2, label %for.body3, label %for.end
31 %add = add nsw i32 %i.0, 1
32 %conv = sext i32 %add to i64
33 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %conv, i1 false)
34 ; MEMOP_ANNOTATION: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %conv, i1 false)
35 ; MEMOP_ANNOTATION-SAME: !prof ![[MEMOP_VALUESITE:[0-9]+]]
36 %memcmp = call i32 @memcmp(i8* %dst, i8* %src, i64 %conv)
37 ; MEMOP_ANNOTATION: call i32 @memcmp(i8* %dst, i8* %src, i64 %conv)
38 ; MEMOP_ANNOTATION-SAME: !prof ![[MEMOP_VALUESITE]]
39 %bcmp = call i32 @bcmp(i8* %dst, i8* %src, i64 %conv)
40 ; MEMOP_ANNOTATION: call i32 @bcmp(i8* %dst, i8* %src, i64 %conv)
41 ; MEMOP_ANNOTATION-SAME: !prof ![[MEMOP_VALUESITE]]
42 ; MEMOP_ANNOTATION9: ![[MEMOP_VALUESITE]] = !{!"VP", i32 1, i64 556, i64 1, i64 99, i64 2, i64 88, i64 3, i64 77, i64 9, i64 72, i64 4, i64 66, i64 5, i64 55, i64 6, i64 44, i64 7, i64 33, i64 8, i64 22}
43 ; MEMOP_ANNOTATION4: ![[MEMOP_VALUESITE]] = !{!"VP", i32 1, i64 556, i64 1, i64 99, i64 2, i64 88, i64 3, i64 77, i64 9, i64 72}
47 %inc = add nsw i32 %j.0, 1
54 %inc5 = add nsw i32 %i.0, 1
61 declare void @llvm.lifetime.start(i64, i8* nocapture)
63 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1)
65 declare i32 @memcmp(i8*, i8*, i64)
66 declare i32 @bcmp(i8*, i8*, i64)
68 declare void @llvm.lifetime.end(i64, i8* nocapture)