[PATCH] D40662: [PGO] Do not do counter promotion for loops without exit blocks ('infinite loops')

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 10:41:26 PST 2017


davidxl created this revision.
Herald added a subscriber: sanjoy.

For those loops, promotion counter can lead to loss of profile as there is no place to sync the counter value back to counter memory.

Test case is included in another patch.


https://reviews.llvm.org/D40662

Files:
  lib/Transforms/Instrumentation/InstrProfiling.cpp


Index: lib/Transforms/Instrumentation/InstrProfiling.cpp
===================================================================
--- lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -245,6 +245,9 @@
   }
 
   bool run(int64_t *NumPromoted) {
+    // Skip 'infinite' loops:
+    if (ExitBlocks.size() == 0)
+      return false;
     unsigned MaxProm = getMaxNumOfPromotionsInLoop(&L);
     if (MaxProm == 0)
       return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40662.124967.patch
Type: text/x-patch
Size: 482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/3e38e6b0/attachment.bin>


More information about the llvm-commits mailing list