[llvm] dbc32e2 - [LoopUnswitch] Use SmallPtrSet instead of std::set. NFCI.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 10:19:40 PST 2022
Author: Benjamin Kramer
Date: 2022-03-11T19:14:34+01:00
New Revision: dbc32e2aa72ed1a46c85160755820c471689dcc1
URL: https://github.com/llvm/llvm-project/commit/dbc32e2aa72ed1a46c85160755820c471689dcc1
DIFF: https://github.com/llvm/llvm-project/commit/dbc32e2aa72ed1a46c85160755820c471689dcc1.diff
LOG: [LoopUnswitch] Use SmallPtrSet instead of std::set. NFCI.
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
index 48ca8499bd200..94e975ccf050d 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -76,7 +76,6 @@
#include <algorithm>
#include <cassert>
#include <map>
-#include <set>
#include <tuple>
#include <utility>
#include <vector>
@@ -904,9 +903,9 @@ bool LoopUnswitch::processCurrentLoop() {
/// If true, we return true and set ExitBB to the block we
/// exit through.
///
-static bool isTrivialLoopExitBlockHelper(Loop *L, BasicBlock *BB,
- BasicBlock *&ExitBB,
- std::set<BasicBlock*> &Visited) {
+static bool
+isTrivialLoopExitBlockHelper(Loop *L, BasicBlock *BB, BasicBlock *&ExitBB,
+ SmallPtrSet<BasicBlock *, 8> &Visited) {
if (!Visited.insert(BB).second) {
// Already visited. Without more analysis, this could indicate an infinite
// loop.
@@ -940,7 +939,7 @@ static bool isTrivialLoopExitBlockHelper(Loop *L, BasicBlock *BB,
/// the specified loop, and has no side-effects in the process. If so, return
/// the block that is exited to, otherwise return null.
static BasicBlock *isTrivialLoopExitBlock(Loop *L, BasicBlock *BB) {
- std::set<BasicBlock*> Visited;
+ SmallPtrSet<BasicBlock *, 8> Visited;
Visited.insert(L->getHeader()); // Branches to header make infinite loops.
BasicBlock *ExitBB = nullptr;
if (isTrivialLoopExitBlockHelper(L, BB, ExitBB, Visited))
More information about the llvm-commits
mailing list