[llvm] r269829 - Simple refactoring /NFC

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 13:19:04 PDT 2016


Author: davidxl
Date: Tue May 17 15:19:03 2016
New Revision: 269829

URL: http://llvm.org/viewvc/llvm-project?rev=269829&view=rev
Log:
Simple refactoring /NFC

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp?rev=269829&r1=269828&r2=269829&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/InstrProfiling.cpp Tue May 17 15:19:03 2016
@@ -367,6 +367,20 @@ InstrProfiling::getOrCreateRegionCounter
   return CounterPtr;
 }
 
+static bool needsRuntimeRegistrationOfSectionRange(const Module &M) {
+  // Don't do this for Darwin.  compiler-rt uses linker magic.
+  if (Triple(M.getTargetTriple()).isOSDarwin())
+    return false;
+
+  // Use linker script magic to get data/cnts/name start/end.
+  if (Triple(M.getTargetTriple()).isOSLinux() ||
+      Triple(M.getTargetTriple()).isOSFreeBSD() ||
+      Triple(M.getTargetTriple()).isPS4CPU())
+    return false;
+
+  return true;
+}
+
 void InstrProfiling::emitNameData() {
   std::string UncompressedData;
 
@@ -391,14 +405,7 @@ void InstrProfiling::emitNameData() {
 }
 
 void InstrProfiling::emitRegistration() {
-  // Don't do this for Darwin.  compiler-rt uses linker magic.
-  if (Triple(M->getTargetTriple()).isOSDarwin())
-    return;
-
-  // Use linker script magic to get data/cnts/name start/end.
-  if (Triple(M->getTargetTriple()).isOSLinux() ||
-      Triple(M->getTargetTriple()).isOSFreeBSD() ||
-      Triple(M->getTargetTriple()).isPS4CPU())
+  if (!needsRuntimeRegistrationOfSectionRange(*M))
     return;
 
   // Construct the function.




More information about the llvm-commits mailing list