Implement mcount profiling, enabled via -pg.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125282 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index 57ddb91..586680b 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -76,6 +76,7 @@
   unsigned char LongLongWidth, LongLongAlign;
   const char *DescriptionString;
   const char *UserLabelPrefix;
+  const char *MCountName;
   const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
   unsigned char RegParmMax, SSERegParmMax;
   TargetCXXABI CXXABI;
@@ -243,6 +244,11 @@
     return UserLabelPrefix;
   }
 
+  /// MCountName - This returns name of the mcount instrumentation function.
+  const char *getMCountName() const {
+    return MCountName;
+  }
+
   bool useBitFieldTypeAlignment() const {
     return UseBitFieldTypeAlignment;
   }
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 3160e96..fda194b 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -191,6 +191,7 @@
   HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard.">;
 def O : Joined<"-O">, HelpText<"Optimization level">;
 def Os : Flag<"-Os">, HelpText<"Optimize for size">;
+def pg : Flag<"-pg">, HelpText<"Enable mcount instrumentation">;
 
 //===----------------------------------------------------------------------===//
 // Dependency Output Options
diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h
index 66c9409..ee85b65 100644
--- a/include/clang/Frontend/CodeGenOptions.h
+++ b/include/clang/Frontend/CodeGenOptions.h
@@ -58,6 +58,7 @@
                                   /// hidden visibility.
   unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is
                                     /// enabled.
+  unsigned InstrumentForProfiling : 1; /// Set when -pg is enabled
   unsigned LessPreciseFPMAD  : 1; /// Enable less precise MAD instructions to be
                                   /// generated.
   unsigned MergeAllConstants : 1; /// Merge identical constants.
@@ -131,6 +132,7 @@
     HiddenWeakTemplateVTables = 0;
     HiddenWeakVTables = 0;
     InstrumentFunctions = 0;
+    InstrumentForProfiling = 0;
     LessPreciseFPMAD = 0;
     MergeAllConstants = 1;
     NoCommon = 0;