[PATCH] D84953: [PGO][test] Add test to check memops changes function hash

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 10:22:51 PDT 2020


yamauchi created this revision.
yamauchi added a reviewer: davidxl.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
yamauchi requested review of this revision.

Following up D84782 <https://reviews.llvm.org/D84782>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84953

Files:
  llvm/test/Transforms/PGOProfile/Inputs/memop_hash.proftext
  llvm/test/Transforms/PGOProfile/memop_hash.ll


Index: llvm/test/Transforms/PGOProfile/memop_hash.ll
===================================================================
--- /dev/null
+++ 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]]
+
Index: llvm/test/Transforms/PGOProfile/Inputs/memop_hash.proftext
===================================================================
--- /dev/null
+++ 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
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84953.281971.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200730/6750b4af/attachment.bin>


More information about the llvm-commits mailing list