[PATCH] D93434: [test] Factor out creation of copy of SCC Nodes into function
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 17 11:39:47 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7529fab602c7: [test] Factor out creation of copy of SCC Nodes into function (authored by aeubanks).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93434/new/
https://reviews.llvm.org/D93434
Files:
llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
Index: llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
===================================================================
--- llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -1714,6 +1714,16 @@
MPM.run(*M, MAM);
}
+// Returns a vector containing the SCC's nodes. Useful for not iterating over an
+// SCC while mutating it.
+static SmallVector<LazyCallGraph::Node *> SCCNodes(LazyCallGraph::SCC &C) {
+ SmallVector<LazyCallGraph::Node *> Nodes;
+ for (auto &N : C)
+ Nodes.push_back(&N);
+
+ return Nodes;
+}
+
// Start with call recursive f, create f -> g and ref recursive f.
TEST_F(CGSCCPassManagerTest, TestInsertionOfNewFunctions1) {
std::unique_ptr<Module> M = parseIR("define void @f() {\n"
@@ -1734,12 +1744,7 @@
auto &FAM =
AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager();
- // Don't iterate over SCC while changing it.
- SmallVector<LazyCallGraph::Node *> Nodes;
- for (auto &N : C)
- Nodes.push_back(&N);
-
- for (LazyCallGraph::Node *N : Nodes) {
+ for (LazyCallGraph::Node *N : SCCNodes(C)) {
Function &F = N->getFunction();
if (F.getName() != "f")
continue;
@@ -1801,12 +1806,7 @@
auto &FAM =
AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager();
- // Don't iterate over SCC while changing it.
- SmallVector<LazyCallGraph::Node *> Nodes;
- for (auto &N : C)
- Nodes.push_back(&N);
-
- for (LazyCallGraph::Node *N : Nodes) {
+ for (LazyCallGraph::Node *N : SCCNodes(C)) {
Function &F = N->getFunction();
if (F.getName() != "f")
continue;
@@ -1908,12 +1908,7 @@
auto &FAM =
AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager();
- // Don't iterate over SCC while changing it.
- SmallVector<LazyCallGraph::Node *> Nodes;
- for (auto &N : C)
- Nodes.push_back(&N);
-
- for (LazyCallGraph::Node *N : Nodes) {
+ for (LazyCallGraph::Node *N : SCCNodes(C)) {
Function &F = N->getFunction();
if (F.getName() != "f1")
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93434.312574.patch
Type: text/x-patch
Size: 2177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201217/b464c1e6/attachment.bin>
More information about the llvm-commits
mailing list