Skip to content

Commit 527f574

Browse files
committed
[Support] Do not use llvm::size in getLoopPreheader
`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. Switch back to the original check.
1 parent a74348c commit 527f574

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/include/llvm/Support/GenericLoopInfoImpl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ 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+
typedef GraphTraits<BlockT *> BlockTraits;
212+
typename BlockTraits::ChildIteratorType SI = BlockTraits::child_begin(Out);
213+
++SI;
214+
if (SI != BlockTraits::child_end(Out))
212215
return nullptr; // Multiple exits from the block, must not be a preheader.
213216

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

0 commit comments

Comments
 (0)