[PGO] Guard the memcmp/bcmp size value profiling instrumentation behind flag.
authorHiroshi Yamauchi <yamauchi@google.com>
Wed, 27 May 2020 17:13:33 +0000 (10:13 -0700)
committerHiroshi Yamauchi <yamauchi@google.com>
Thu, 28 May 2020 17:07:04 +0000 (10:07 -0700)
Summary:
Follow up D79751 and put the instrumentation / value collection side (in
addition to the optimization side) behind the flag as well.

Reviewers: davidxl

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80646

llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
llvm/lib/Transforms/Instrumentation/ValueProfilePlugins.inc
llvm/test/Transforms/PGOProfile/memop_size_annotation.ll

index bef0e0257f029d1efef5d90ea175eb91c241d73e..604a20f3951a6988b968fafc75e32d2d5f304c73 100644 (file)
@@ -95,7 +95,7 @@ extern cl::opt<std::string> MemOPSizeRange;
 // This option sets the value that groups large memop sizes
 extern cl::opt<unsigned> MemOPSizeLarge;
 
-static cl::opt<bool>
+cl::opt<bool>
     MemOPOptMemcmpBcmp("pgo-memop-optimize-memcmp-bcmp", cl::init(false),
                        cl::Hidden,
                        cl::desc("Size-specialize memcmp and bcmp calls"));
index b5dd9fab24a541bfd08e2155dc2bff76bbe6ffa9..8d0cf5843ebce12becfe3c2274ddaaab07ae732a 100644 (file)
@@ -20,6 +20,8 @@
 using namespace llvm;
 using CandidateInfo = ValueProfileCollector::CandidateInfo;
 
+extern cl::opt<bool> MemOPOptMemcmpBcmp;
+
 ///--------------------------- MemIntrinsicPlugin ------------------------------
 class MemIntrinsicPlugin : public InstVisitor<MemIntrinsicPlugin> {
   Function &F;
@@ -48,6 +50,8 @@ public:
     Candidates->emplace_back(CandidateInfo{Length, InsertPt, AnnotatedInst});
   }
   void visitCallInst(CallInst &CI) {
+    if (!MemOPOptMemcmpBcmp)
+      return;
     auto *F = CI.getCalledFunction();
     if (!F)
       return;
index 5884a6ebbb25d02cd1051dcf5148c9ba2dff16a3..f57f3d34f4ac5f694d92ddb9f6f4e3c5ea83df26 100644 (file)
@@ -1,8 +1,8 @@
 ; RUN: llvm-profdata merge %S/Inputs/memop_size_annotation.proftext -o %t.profdata
-; RUN: opt < %s -pgo-instr-use -memop-max-annotations=9 -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION9
-; RUN: opt < %s -passes=pgo-instr-use -memop-max-annotations=9 -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION9
-; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION4
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefixes=MEMOP_ANNOTATION,MEMOP_ANNOTATION4
+; 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
+; 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
+; 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
+; 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
 
 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"