diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memop_hash.proftext b/llvm/test/Transforms/PGOProfile/Inputs/memop_hash.proftext new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/PGOProfile/Inputs/memop_hash.proftext @@ -0,0 +1,25 @@ +:ir +foo1 +# Func Hash: +48277136972185599 +# Num Counters: +1 +# Counter Values: +1 +# Num Value Kinds: +1 +# ValueKind = IPVK_MemOPSize: +1 +# NumValueSites: +1 +1 +2:100 + +foo2 +# Func Hash: +742261418966908927 +# Num Counters: +1 +# Counter Values: +2 + diff --git a/llvm/test/Transforms/PGOProfile/memop_hash.ll b/llvm/test/Transforms/PGOProfile/memop_hash.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/PGOProfile/memop_hash.ll @@ -0,0 +1,27 @@ +; RUN: llvm-profdata merge %S/Inputs/memop_hash.proftext -o %t.profdata +; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck -check-prefix=MISMATCH %s +; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck -check-prefix=MISMATCH %s +; RUN: llvm-profdata show -function=foo %t.profdata | FileCheck %s + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) + +; MISMATCH-NOT: hash mismatch + +define i64 @foo1(i8* %a, i8* %b, i32 %s) { +entry: + call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %b, i32 %s, i1 false); + ret i64 0 +} + +define i64 @foo2(i8* %a, i8* %b, i32 %s) { +entry: + ret i64 0 +} + +; The two hashes should not be equal as the existence of the memcpy should change the hash. +; CHECK: [[HASH1:0x[0-9a-f]+]] +; CHECK-NOT: [[HASH1]] +