diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -63,6 +63,7 @@ DebugInfoCorrelate("debug-info-correlate", cl::desc("Use debug info to correlate profiles."), cl::init(false)); +extern cl::opt DisableValueProfiling; } // namespace llvm namespace { @@ -777,8 +778,9 @@ } static bool enablesValueProfiling(const Module &M) { - return isIRPGOFlagSet(&M) || - getIntModuleFlagOrZero(M, "EnableValueProfiling") != 0; + return (isIRPGOFlagSet(&M) || + getIntModuleFlagOrZero(M, "EnableValueProfiling") != 0) && + !DisableValueProfiling; } // Conservatively returns true if data variables may be referenced by code. diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -172,12 +172,6 @@ cl::desc("Specify the path of profile remapping file. This is mainly for " "test purpose.")); -// Command line option to disable value profiling. The default is false: -// i.e. value profiling is enabled by default. This is for debug purpose. -static cl::opt DisableValueProfiling("disable-vp", cl::init(false), - cl::Hidden, - cl::desc("Disable Value Profiling")); - // Command line option to set the maximum number of VP annotations to write to // the metadata for a single indirect call callsite. static cl::opt MaxNumAnnotations( @@ -214,6 +208,11 @@ NoPGOWarnMismatch("no-pgo-warn-mismatch", cl::init(false), cl::Hidden, cl::desc("Use this option to turn off/on " "warnings about profile cfg mismatch.")); +// Command line option to disable value profiling. The default is false: +// i.e. value profiling is enabled by default. This is for debug purpose. +cl::opt DisableValueProfiling("disable-vp", cl::init(false), cl::Hidden, + cl::desc("Disable Value Profiling")); + } // namespace llvm // Command line option to enable/disable the warning about a hash mismatch in diff --git a/llvm/test/Instrumentation/InstrProfiling/comdat.ll b/llvm/test/Instrumentation/InstrProfiling/comdat.ll --- a/llvm/test/Instrumentation/InstrProfiling/comdat.ll +++ b/llvm/test/Instrumentation/InstrProfiling/comdat.ll @@ -10,6 +10,7 @@ ; RUN: cat %t/main.ll %t/enable.ll > %t1.ll ; RUN: opt < %t0.ll -mtriple=x86_64-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELF0 ; RUN: opt < %t1.ll -mtriple=x86_64-linux -passes=instrprof -S | FileCheck %s --check-prefixes=ELF,ELF1 +; RUN: opt < %t1.ll -mtriple=x86_64-linux -passes=instrprof -disable-vp -S | FileCheck %s --check-prefixes=ELF,ELF0 ; RUN: opt < %t0.ll -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=COFF,COFF0 ; RUN: opt < %t1.ll -mtriple=x86_64-windows -passes=instrprof -S | FileCheck %s --check-prefixes=COFF,COFF1