[llvm] r340545 - [llvm-mca] Fix wrong call to setCustomStrategy().

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 23 10:09:08 PDT 2018


Author: adibiagio
Date: Thu Aug 23 10:09:08 2018
New Revision: 340545

URL: http://llvm.org/viewvc/llvm-project?rev=340545&view=rev
Log:
[llvm-mca] Fix wrong call to setCustomStrategy().

Thanks to @waltl for reporting this issue.

I have also added an assert to check for invalid null strategy objects, and I
have reworded a couple of code comments in Scheduler.h

Modified:
    llvm/trunk/tools/llvm-mca/Scheduler.cpp
    llvm/trunk/tools/llvm-mca/Scheduler.h

Modified: llvm/trunk/tools/llvm-mca/Scheduler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Scheduler.cpp?rev=340545&r1=340544&r2=340545&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Scheduler.cpp (original)
+++ llvm/trunk/tools/llvm-mca/Scheduler.cpp Thu Aug 23 10:09:08 2018
@@ -115,6 +115,7 @@ void ResourceManager::setCustomStrategyI
                                             uint64_t ResourceID) {
   unsigned Index = getResourceStateIndex(ResourceID);
   assert(Index < Resources.size() && "Invalid processor resource index!");
+  assert(S && "Unexpected null strategy in input!");
   Strategies[Index].reset(S.get());
 }
 

Modified: llvm/trunk/tools/llvm-mca/Scheduler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mca/Scheduler.h?rev=340545&r1=340544&r2=340545&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mca/Scheduler.h (original)
+++ llvm/trunk/tools/llvm-mca/Scheduler.h Thu Aug 23 10:09:08 2018
@@ -83,10 +83,9 @@ class DefaultResourceStrategy final : pu
   ///   ResourceB -- 0b010
   ///   ResourceC -- 0b100
   ///
-  /// Field NextInSequenceMask is used by class ResourceManager to select the
-  /// "next available resource" from the set.
-  /// It defaults to the value of field `ResourceUnitMasks`. In this example, it
-  /// defaults to mask '0b111'.
+  /// Field NextInSequenceMask is used to select the next unit from the set of
+  /// resource units. It defaults to the value of field `ResourceUnitMasks` (in
+  /// this example, it defaults to mask '0b111').
   ///
   /// The round-robin selector would firstly select 'ResourceC', then
   /// 'ResourceB', and eventually 'ResourceA'.  When a resource R is used, the
@@ -99,19 +98,19 @@ class DefaultResourceStrategy final : pu
   uint64_t NextInSequenceMask;
 
   /// This field is used to track resource units that are used (i.e. selected)
-  /// by other groups other than this one.
+  /// by other groups other than the one associated with this strategy object.
   ///
   /// In LLVM processor resource groups are allowed to partially (or fully)
   /// overlap. That means, a same unit may be visible to multiple groups.
-  /// This field keeps track of uses that have been initiated from outside of
+  /// This field keeps track of uses that have originated from outside of
   /// this group. The idea is to bias the selection strategy, so that resources
   /// that haven't been used by other groups get prioritized.
   ///
   /// The end goal is to (try to) keep the resource distribution as much uniform
   /// as possible. By construction, this mask only tracks one-level of resource
   /// usage. Therefore, this strategy is expected to be less accurate when same
-  /// units are used multiple times from outside of this group during a single
-  /// selection round.
+  /// units are used multiple times by other groups within a single round of
+  /// select.
   ///
   /// Note: an LRU selector would have a better accuracy at the cost of being
   /// slightly more expensive (mostly in terms of runtime cost). Methods
@@ -315,7 +314,7 @@ public:
                          unsigned ResourceID) {
     assert(ResourceID < ProcResID2Mask.size() &&
            "Invalid resource index in input!");
-    return setCustomStrategy(std::move(S), ProcResID2Mask[ResourceID]);
+    return setCustomStrategyImpl(std::move(S), ProcResID2Mask[ResourceID]);
   }
 
   // Returns RS_BUFFER_AVAILABLE if buffered resources are not reserved, and if




More information about the llvm-commits mailing list