Skip to content

Commit 6885281

Browse files
authored
[Support] Do not use llvm::size in getLoopPreheader (#94540)
`BlockT *LoopBase<BlockT, LoopT>::getLoopPreheader()` was changed in 7243607 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.
1 parent 3f0f2cd commit 6885281

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/Support/GenericLoopInfoImpl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ BlockT *LoopBase<BlockT, LoopT>::getLoopPreheader() const {
208208
return nullptr;
209209

210210
// Make sure there is only one exit out of the preheader.
211-
if (llvm::size(llvm::children<BlockT *>(Out)) != 1)
211+
if (!llvm::hasSingleElement(llvm::children<BlockT *>(Out)))
212212
return nullptr; // Multiple exits from the block, must not be a preheader.
213213

214214
// The predecessor has exactly one successor, so it is a preheader.

0 commit comments

Comments
 (0)