[PGO] Do not emit runtime hook user function for Linux
[oota-llvm.git] / lib / Transforms / Instrumentation / InstrProfiling.cpp
index 55fd86f71720b31712a244bccea64c4217a95733..493c70e8fd6cd017bfb9922636e5c87baf3cde60 100644 (file)
@@ -288,6 +288,11 @@ void InstrProfiling::emitRegistration() {
 
 void InstrProfiling::emitRuntimeHook() {
 
+  // We expect the linker to be invoked with -u<hook_var> flag for linux,
+  // for which case there is no need to emit the user function.
+  if (Triple(M->getTargetTriple()).isOSLinux())
+    return;
+
   // If the module's provided its own runtime, we don't need to do anything.
   if (M->getGlobalVariable(getInstrProfRuntimeHookVarName())) return;