[llvm] 446b150 - [IR] Update BasicBlock::validateInstrOrdering comments, NFC

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 21 12:34:41 PST 2020


Author: Reid Kleckner
Date: 2020-02-21T12:33:16-08:00
New Revision: 446b150065c331daa82a9f5436f4987e340e5d6f

URL: https://github.com/llvm/llvm-project/commit/446b150065c331daa82a9f5436f4987e340e5d6f
DIFF: https://github.com/llvm/llvm-project/commit/446b150065c331daa82a9f5436f4987e340e5d6f.diff

LOG: [IR] Update BasicBlock::validateInstrOrdering comments, NFC

Pointed out by Jay Foad.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 4a3c649c7af2..1210ed1eb2ef 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -455,9 +455,14 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
   /// 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:

diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 679c72fd3dd7..675deea1d755 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -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;


        


More information about the llvm-commits mailing list