Driver/Darwin: Be bug compatible with GCC and ignore -pg on ARM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126767 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 561476e..4a9be0e 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -918,6 +918,11 @@
   return 0;
 }
 
+bool Darwin::SupportsProfiling() const {
+  // Profiling instrumentation is only supported on x86.
+  return getArchName() == "i386" || getArchName() == "x86_64";
+}
+
 bool Darwin::SupportsObjCGC() const {
   // Garbage collection is supported everywhere except on iPhone OS.
   return !isTargetIPhoneOS();
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index 0e3645c..3c0def5 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -212,6 +212,8 @@
   virtual const char *GetDefaultRelocationModel() const;
   virtual const char *GetForcedPicModel() const;
 
+  virtual bool SupportsProfiling() const;
+
   virtual bool SupportsObjCGC() const;
 
   virtual bool UseDwarfDebugFlags() const;
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 3e6f748..8539752 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1385,7 +1385,8 @@
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_flimit_debug_info);
-  Args.AddLastArg(CmdArgs, options::OPT_pg);
+  if (getToolChain().SupportsProfiling())
+    Args.AddLastArg(CmdArgs, options::OPT_pg);
 
   // -flax-vector-conversions is default.
   if (!Args.hasFlag(options::OPT_flax_vector_conversions,
@@ -2184,7 +2185,8 @@
 
   if (Args.hasArg(options::OPT_v))
     CmdArgs.push_back("-version");
-  if (Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_pg) &&
+      getToolChain().SupportsProfiling())
     CmdArgs.push_back("-p");
   Args.AddLastArg(CmdArgs, options::OPT_p);
 
@@ -2817,7 +2819,8 @@
           }
         }
       } else {
-        if (Args.hasArg(options::OPT_pg)) {
+        if (Args.hasArg(options::OPT_pg) &&
+            getToolChain().SupportsProfiling()) {
           if (Args.hasArg(options::OPT_static) ||
               Args.hasArg(options::OPT_object) ||
               Args.hasArg(options::OPT_preload)) {