From 3d0d61496e0b592e79dd92aa74bedfa2e2ddd5c2 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Sun, 28 Apr 2024 18:55:09 -0700 Subject: [PATCH] [Support] Do not use `llvm::size` in `getLoopPreheader` `BlockT *LoopBase::getLoopPreheader()` was changed in 7243607867393a2b8ccd477e95e6f62d00f3206f to use `llvm::size` rather than the checking that `child_begin() + 1 == child_end()`. `llvm::size` requires that `std::distance` be O(1) and hence that clients support random access. Use `llvm::hasSingleElement` instead. --- llvm/include/llvm/Support/GenericLoopInfoImpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/GenericLoopInfoImpl.h b/llvm/include/llvm/Support/GenericLoopInfoImpl.h index 1e0d0ee446fc4..d19022729ace3 100644 --- a/llvm/include/llvm/Support/GenericLoopInfoImpl.h +++ b/llvm/include/llvm/Support/GenericLoopInfoImpl.h @@ -208,7 +208,7 @@ BlockT *LoopBase::getLoopPreheader() const { return nullptr; // Make sure there is only one exit out of the preheader. - if (llvm::size(llvm::children(Out)) != 1) + if (!llvm::hasSingleElement(llvm::children(Out))) return nullptr; // Multiple exits from the block, must not be a preheader. // The predecessor has exactly one successor, so it is a preheader.