Add GCC-compatible flags -fprofile-generate and -fprofile-use

Diego Novillo dnovillo at google.com
Mon Jun 29 13:07:59 PDT 2015


This update removes the separate tracking of profile directory and
name. If a directory is given, it automatically sets the profile name
to be <DIR>/default.profraw.


Diego.
-------------- next part --------------
commit 37eed11f12fe7728fccb44ed3665315d92c013a9
Author: Diego Novillo <dnovillo at google.com>
Date:   Mon Jun 29 16:01:37 2015 -0400

    Remove separate tracking of profile directory and profile name.

diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h
index 8c199d2..53246bc 100644
--- a/include/clang/Frontend/CodeGenOptions.h
+++ b/include/clang/Frontend/CodeGenOptions.h
@@ -154,10 +154,6 @@ public:
   /// A list of dependent libraries.
   std::vector<std::string> DependentLibraries;
 
-  /// Name of the directory where to save the profile file specified in
-  /// -fprofile-generate.
-  std::string InstrProfileDir;
-
   /// Name of the profile file to use as output for -fprofile-instr-generate
   /// and -fprofile-generate.
   std::string InstrProfileOutput;
diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp
index 663a38a..801b49f 100644
--- a/lib/CodeGen/BackendUtil.cpp
+++ b/lib/CodeGen/BackendUtil.cpp
@@ -415,7 +415,6 @@ void EmitAssemblyHelper::CreatePasses() {
   if (CodeGenOpts.ProfileInstrGenerate) {
     InstrProfOptions Options;
     Options.NoRedZone = CodeGenOpts.DisableRedZone;
-    Options.InstrProfileDir = CodeGenOpts.InstrProfileDir;
     Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
     MPM->add(createInstrProfilingPass(Options));
   }
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index d212be8..7e46094 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -452,7 +452,13 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
                               Args.hasArg(OPT_fprofile_generate) ||
                               Args.hasArg(OPT_fprofile_generate_EQ);
   Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instr_generate_EQ);
-  Opts.InstrProfileDir = Args.getLastArgValue(OPT_fprofile_generate_EQ);
+  if (Opts.InstrProfileOutput.empty()) {
+    SmallString<128> Dir(Args.getLastArgValue(OPT_fprofile_generate_EQ));
+    if (!Dir.empty()) {
+      llvm::sys::path::append(Dir, "default.profraw");
+      Opts.InstrProfileOutput = Dir.str();
+    }
+  }
   Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ);
   if (Opts.InstrProfileInput.empty()) {
     SmallString<128> Filename(Args.getLastArgValue(OPT_fprofile_use_EQ));


More information about the cfe-commits mailing list