aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2020-09-29 15:53:41 -0700
committerTeresa Johnson <tejohnson@google.com>2020-11-01 17:38:23 -0800
commit0949f96dc6521be80ebb8ebc1e1c506165c22aac (patch)
tree9c257f41cec0e210f929754ed9c601c03847275e /clang/lib/CodeGen/CodeGenModule.cpp
parentcc91554ebb66e8c9a4b8c67ca2f1343eaac10cf6 (diff)
downloadllvm-0949f96dc6521be80ebb8ebc1e1c506165c22aac.zip
llvm-0949f96dc6521be80ebb8ebc1e1c506165c22aac.tar.gz
llvm-0949f96dc6521be80ebb8ebc1e1c506165c22aac.tar.bz2
[MemProf] Pass down memory profile name with optional path from clang
Similar to -fprofile-generate=, add -fmemory-profile= which takes a directory path. This is passed down to LLVM via a new module flag metadata. LLVM in turn provides this name to the runtime via the new __memprof_profile_filename variable. Additionally, always pass a default filename (in $cwd if a directory name is not specified vi the = form of the option). This is also consistent with the behavior of the PGO instrumentation. Since the memory profiles will generally be fairly large, it doesn't make sense to dump them to stderr. Also, importantly, the memory profiles will eventually be dumped in a compact binary format, which is another reason why it does not make sense to send these to stderr by default. Change the existing memprof tests to specify log_path=stderr when that was being relied on. Depends on D89086. Differential Revision: https://reviews.llvm.org/D89087
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 2a7fb4f..66a3c57 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -607,6 +607,13 @@ void CodeGenModule::Release() {
!LangOpts.isSignReturnAddressWithAKey());
}
+ if (!CodeGenOpts.MemoryProfileOutput.empty()) {
+ llvm::LLVMContext &Ctx = TheModule.getContext();
+ getModule().addModuleFlag(
+ llvm::Module::Error, "MemProfProfileFilename",
+ llvm::MDString::get(Ctx, CodeGenOpts.MemoryProfileOutput));
+ }
+
if (LangOpts.CUDAIsDevice && getTriple().isNVPTX()) {
// Indicate whether __nvvm_reflect should be configured to flush denormal
// floating point values to 0. (This corresponds to its "__CUDA_FTZ"