]> granicus.if.org Git - llvm/commitdiff
[SelectionDAG] Add static getMaxNumOperands function to SDNode.
authorFlorian Hahn <flo@fhahn.com>
Fri, 18 Jan 2019 10:00:38 +0000 (10:00 +0000)
committerFlorian Hahn <flo@fhahn.com>
Fri, 18 Jan 2019 10:00:38 +0000 (10:00 +0000)
Summary:
Use this helper to make sure we use the same value at various places.
This will likely be needed at more places were we currently crash
because we use more operands than possible.

Also makes it easier to change in the future.

Reviewers: RKSimon, craig.topper, efriedma, aemerson

Reviewed By: RKSimon

Subscribers: hiraditya, arsenm, llvm-commits

Differential Revision: https://reviews.llvm.org/D56859

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351537 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

index 10f28417908459691ab6d832b6ee57d513a48e1d..f7554ad664886416f9e8d0c7570ae3e0a05f2916 100644 (file)
@@ -898,6 +898,11 @@ public:
   /// Return the number of values used by this operation.
   unsigned getNumOperands() const { return NumOperands; }
 
+  /// Return the maximum number of operands that a SDNode can hold.
+  static constexpr size_t getMaxNumOperands() {
+    return std::numeric_limits<decltype(SDNode::NumOperands)>::max();
+  }
+
   /// Helper method returns the integer value of a ConstantSDNode operand.
   inline uint64_t getConstantOperandVal(unsigned Num) const;
 
index 647496c1afcb92d006f992112fa6e9493ae84391..af81216e34492f3147131f5aa76ee34c079234b5 100644 (file)
@@ -9266,8 +9266,7 @@ SDNode *SelectionDAG::isConstantFPBuildVectorOrConstantFP(SDValue N) {
 
 void SelectionDAG::createOperands(SDNode *Node, ArrayRef<SDValue> Vals) {
   assert(!Node->OperandList && "Node already has operands");
-  assert(std::numeric_limits<decltype(SDNode::NumOperands)>::max() >=
-             Vals.size() &&
+  assert(SDNode::getMaxNumOperands() >= Vals.size() &&
          "too many operands to fit into SDNode");
   SDUse *Ops = OperandRecycler.allocate(
       ArrayRecycler<SDUse>::Capacity::get(Vals.size()), OperandAllocator);
index 3390703c7baea4a4ed918878c34615feaa3aa613..9f09f25f2ffd7c6a1cab16533a8081612509b79a 100644 (file)
@@ -1035,7 +1035,7 @@ SDValue SelectionDAGBuilder::getRoot() {
   // If we have >= 2^16 loads then split across multiple token factors as
   // there's a 64k limit on the number of SDNode operands.
   SDValue Root;
-  size_t Limit = (1 << 16) - 1;
+  size_t Limit = SDNode::getMaxNumOperands();
   while (PendingLoads.size() > Limit) {
     unsigned SliceIdx = PendingLoads.size() - Limit;
     auto ExtractedTFs = ArrayRef<SDValue>(PendingLoads).slice(SliceIdx, Limit);