[IR] Update BasicBlock::validateInstrOrdering comments, NFC
authorReid Kleckner <rnk@google.com>
Fri, 21 Feb 2020 20:31:00 +0000 (12:31 -0800)
committerReid Kleckner <rnk@google.com>
Fri, 21 Feb 2020 20:33:16 +0000 (12:33 -0800)
Pointed out by Jay Foad.

llvm/include/llvm/IR/BasicBlock.h
llvm/lib/IR/BasicBlock.cpp

index 4a3c649..1210ed1 100644 (file)
@@ -455,9 +455,14 @@ public:
   /// Renumber instructions and mark the ordering as valid.
   void renumberInstructions();
 
-  /// Returns false if the instruction ordering is incorrect in an debug build.
-  /// Always returns true when assertions are disabled. The method does not
-  /// assert internally so that we get better location info.
+  /// Asserts that instruction order numbers are marked invalid, or that they
+  /// are in ascending order. This is constant time if the ordering is invalid,
+  /// and linear in the number of instructions if the ordering is valid. Callers
+  /// should be careful not to call this in ways that make common operations
+  /// O(n^2). For example, it takes O(n) time to assign order numbers to
+  /// instructions, so the order should be validated no more than once after
+  /// each ordering to ensure that transforms have the same algorithmic
+  /// complexity when asserts are enabled as when they are disabled.
   void validateInstrOrdering() const;
 
 private:
index 679c72f..675deea 100644 (file)
@@ -526,7 +526,7 @@ void BasicBlock::renumberInstructions() {
 
 #ifndef NDEBUG
 /// In asserts builds, this checks the numbering. In non-asserts builds, it
-/// is defined as an inline function returning true in BasicBlock.h.
+/// is defined as a no-op inline function in BasicBlock.h.
 void BasicBlock::validateInstrOrdering() const {
   if (!isInstrOrderValid())
     return;