https://bugs.llvm.org/show_bug.cgi?id=47502
Bug ID: 47502
Summary: Cannot add mutually recursive functions into RefSCC
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: aeuba...@google.com
CC: alina.sbir...@gmail.com, htmldevelo...@gmail.com,
johan...@jdoerfert.de, llvm-bugs@lists.llvm.org,
modoca...@gmail.com
When adding mutually recursive (ref-wise) functions to a CGSCC via
LazyCallGraph::addNewFunctionIntoRefSCC(), the following assert triggers:
Assertion failed: !lookup(F) && "node already exists", file
../../llvm/lib/Analysis/LazyCallGraph.cpp, line 1598
This is because addNewFunctionIntoRefSCC() calls createNode(), which populates
the edges for that node and creates nodes for any functions it references by
calling get(). Let's say we want to call addNewFunctionIntoRefSCC() on two
newly created and mutually recursive functions. After the first
addNewFunctionIntoRefSCC(), it has created two nodes, one for each of the newly
added functions. Then in the second call to addNewFunctionIntoRefSCC(), it
calls createNode() on the second function, but the node was already created via
a call to get() previously, so the assert triggers.
https://reviews.llvm.org/D72025 and https://reviews.llvm.org/D70927 introduced
addNewFunctionIntoSCC() and addNewFunctionIntoRefSCC().
Reproducible via unittests with the diff in CGSCCCPassManagerTest.cpp below:
```
@@ -1753,11 +1753,29 @@ TEST_F(CGSCCPassManagerTest, TestInsertionOfNewRefSCC)
{
Type::getInt8PtrTy(F.getContext()),
"f.ref", &*F.begin()->begin());
+ // Create mutually recursive functions 'h1' and 'h2'.
+ auto *H1 = Function::Create(F.getFunctionType(), F.getLinkage(),
+ F.getAddressSpace(), "h1",
F.getParent());
+ auto *H2 = Function::Create(F.getFunctionType(), F.getLinkage(),
+ F.getAddressSpace(), "h2",
F.getParent());
+ BasicBlock *H1BB =
+ BasicBlock::Create(F.getParent()->getContext(), "entry", H1);
+ BasicBlock *H2BB =
+ BasicBlock::Create(F.getParent()->getContext(), "entry", H2);
+ (void)CallInst::Create(H2, {}, "", H1BB);
+ ReturnInst::Create(H1->getContext(), H1BB);
+ (void)CallInst::Create(H1, {}, "", H2BB);
+ ReturnInst::Create(H2->getContext(), H2BB);
+
+ CG.addNewFunctionIntoRefSCC(*H1, C.getOuterRefSCC());
+ CG.addNewFunctionIntoRefSCC(*H2, C.getOuterRefSCC());
+
+ F.getParent()->dump();
ASSERT_NO_FATAL_FAILURE(
updateCGAndAnalysisManagerForCGSCCPass(CG, C, N, AM, UR, FAM))
<< "Updating the call graph with a demoted, self-referential "
- "call edge 'f -> f', and a newly inserted ref edge 'f -> g',
"
- "caused a fatal failure";
+ "call edge 'f -> f', a newly inserted ref edge 'f -> g', and
"
+ "mutually recursive h1 <-> h2 caused a fatal failure";
}
```
$ ./build/debug/obj/llvm/unittests/Analysis/AnalysisTests.exe
--gtest_filter='*TestInsertionOfNew*' --gtest_catch_exceptions=0
Note: Google Test filter = *TestInsertionOfNew*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from CGSCCPassManagerTest
[ RUN ] CGSCCPassManagerTest.TestInsertionOfNewRefSCC
Starting llvm::Module pass manager run.
Starting CGSCC pass manager run.
Assertion failed: !lookup(F) && "node already exists", file
../../llvm/lib/Analysis/LazyCallGraph.cpp, line 1598
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs