summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/Analysis')
-rw-r--r--llvm/unittests/Analysis/AliasAnalysisTest.cpp5
-rw-r--r--llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp2
-rw-r--r--llvm/unittests/Analysis/CFGTest.cpp3
-rw-r--r--llvm/unittests/Analysis/CGSCCPassManagerTest.cpp69
-rw-r--r--llvm/unittests/Analysis/CallGraphTest.cpp6
-rw-r--r--llvm/unittests/Analysis/LazyCallGraphTest.cpp494
-rw-r--r--llvm/unittests/Analysis/LoopPassManagerTest.cpp46
-rw-r--r--llvm/unittests/Analysis/UnrollAnalyzer.cpp21
-rw-r--r--llvm/unittests/Analysis/ValueTrackingTest.cpp3
9 files changed, 332 insertions, 317 deletions
diff --git a/llvm/unittests/Analysis/AliasAnalysisTest.cpp b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
index 3ef635cf3b0..40436ef99b8 100644
--- a/llvm/unittests/Analysis/AliasAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/AliasAnalysisTest.cpp
@@ -207,14 +207,13 @@ TEST_F(AliasAnalysisTest, getModRefInfo) {
class AAPassInfraTest : public testing::Test {
protected:
- LLVMContext &C;
+ LLVMContext C;
SMDiagnostic Err;
std::unique_ptr<Module> M;
public:
AAPassInfraTest()
- : C(getGlobalContext()),
- M(parseAssemblyString("define i32 @f(i32* %x, i32* %y) {\n"
+ : M(parseAssemblyString("define i32 @f(i32* %x, i32* %y) {\n"
"entry:\n"
" %lx = load i32, i32* %x\n"
" %ly = load i32, i32* %y\n"
diff --git a/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp b/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
index 64516373e8e..b3b0fcfb049 100644
--- a/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
+++ b/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
@@ -30,6 +30,7 @@ protected:
std::unique_ptr<BranchProbabilityInfo> BPI;
std::unique_ptr<DominatorTree> DT;
std::unique_ptr<LoopInfo> LI;
+ LLVMContext C;
BlockFrequencyInfo buildBFI(Function &F) {
DT.reset(new DominatorTree(F));
@@ -50,7 +51,6 @@ protected:
" %y2 = phi i32 [0, %bb1], [1, %bb2] \n"
" ret i32 %y2\n"
"}\n";
- LLVMContext &C = getGlobalContext();
SMDiagnostic Err;
return parseAssemblyString(ModuleStrig, Err, C);
}
diff --git a/llvm/unittests/Analysis/CFGTest.cpp b/llvm/unittests/Analysis/CFGTest.cpp
index 44f0fe681df..c60044fa52d 100644
--- a/llvm/unittests/Analysis/CFGTest.cpp
+++ b/llvm/unittests/Analysis/CFGTest.cpp
@@ -31,7 +31,7 @@ class IsPotentiallyReachableTest : public testing::Test {
protected:
void ParseAssembly(const char *Assembly) {
SMDiagnostic Error;
- M = parseAssemblyString(Assembly, Error, getGlobalContext());
+ M = parseAssemblyString(Assembly, Error, Context);
std::string errMsg;
raw_string_ostream os(errMsg);
@@ -112,6 +112,7 @@ protected:
PM.run(*M);
}
+ LLVMContext Context;
std::unique_ptr<Module> M;
Instruction *A, *B;
};
diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index 857c84d5016..7f6e4d13ff8 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -209,51 +209,50 @@ struct TestFunctionPass {
int &RunCount;
};
-std::unique_ptr<Module> parseIR(const char *IR) {
- LLVMContext &C = getGlobalContext();
+std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
SMDiagnostic Err;
return parseAssemblyString(IR, Err, C);
}
class CGSCCPassManagerTest : public ::testing::Test {
protected:
+ LLVMContext Context;
std::unique_ptr<Module> M;
public:
CGSCCPassManagerTest()
- : M(parseIR("define void @f() {\n"
- "entry:\n"
- " call void @g()\n"
- " call void @h1()\n"
- " ret void\n"
- "}\n"
- "define void @g() {\n"
- "entry:\n"
- " call void @g()\n"
- " call void @x()\n"
- " ret void\n"
- "}\n"
- "define void @h1() {\n"
- "entry:\n"
- " call void @h2()\n"
- " ret void\n"
- "}\n"
- "define void @h2() {\n"
- "entry:\n"
- " call void @h3()\n"
- " call void @x()\n"
- " ret void\n"
- "}\n"
- "define void @h3() {\n"
- "entry:\n"
- " call void @h1()\n"
- " ret void\n"
- "}\n"
- "define void @x() {\n"
- "entry:\n"
- " ret void\n"
- "}\n"
- )) {}
+ : M(parseIR(Context, "define void @f() {\n"
+ "entry:\n"
+ " call void @g()\n"
+ " call void @h1()\n"
+ " ret void\n"
+ "}\n"
+ "define void @g() {\n"
+ "entry:\n"
+ " call void @g()\n"
+ " call void @x()\n"
+ " ret void\n"
+ "}\n"
+ "define void @h1() {\n"
+ "entry:\n"
+ " call void @h2()\n"
+ " ret void\n"
+ "}\n"
+ "define void @h2() {\n"
+ "entry:\n"
+ " call void @h3()\n"
+ " call void @x()\n"
+ " ret void\n"
+ "}\n"
+ "define void @h3() {\n"
+ "entry:\n"
+ " call void @h1()\n"
+ " ret void\n"
+ "}\n"
+ "define void @x() {\n"
+ "entry:\n"
+ " ret void\n"
+ "}\n")) {}
};
TEST_F(CGSCCPassManagerTest, Basic) {
diff --git a/llvm/unittests/Analysis/CallGraphTest.cpp b/llvm/unittests/Analysis/CallGraphTest.cpp
index 777907a55b1..af46291074c 100644
--- a/llvm/unittests/Analysis/CallGraphTest.cpp
+++ b/llvm/unittests/Analysis/CallGraphTest.cpp
@@ -44,14 +44,16 @@ template <typename Ty> void canSpecializeGraphTraitsIterators(Ty *G) {
}
TEST(CallGraphTest, GraphTraitsSpecialization) {
- Module M("", getGlobalContext());
+ LLVMContext Context;
+ Module M("", Context);
CallGraph CG(M);
canSpecializeGraphTraitsIterators(&CG);
}
TEST(CallGraphTest, GraphTraitsConstSpecialization) {
- Module M("", getGlobalContext());
+ LLVMContext Context;
+ Module M("", Context);
CallGraph CG(M);
canSpecializeGraphTraitsIterators(const_cast<const CallGraph *>(&CG));
diff --git a/llvm/unittests/Analysis/LazyCallGraphTest.cpp b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
index 457c07dc308..224a9458cc8 100644
--- a/llvm/unittests/Analysis/LazyCallGraphTest.cpp
+++ b/llvm/unittests/Analysis/LazyCallGraphTest.cpp
@@ -21,10 +21,10 @@ using namespace llvm;
namespace {
-std::unique_ptr<Module> parseAssembly(const char *Assembly) {
+std::unique_ptr<Module> parseAssembly(LLVMContext &Context,
+ const char *Assembly) {
SMDiagnostic Error;
- std::unique_ptr<Module> M =
- parseAssemblyString(Assembly, Error, getGlobalContext());
+ std::unique_ptr<Module> M = parseAssemblyString(Assembly, Error, Context);
std::string ErrMsg;
raw_string_ostream OS(ErrMsg);
@@ -121,7 +121,8 @@ static const char DiamondOfTriangles[] =
"}\n";
TEST(LazyCallGraphTest, BasicGraphFormation) {
- std::unique_ptr<Module> M = parseAssembly(DiamondOfTriangles);
+ LLVMContext Context;
+ std::unique_ptr<Module> M = parseAssembly(Context, DiamondOfTriangles);
LazyCallGraph CG(*M);
// The order of the entry nodes should be stable w.r.t. the source order of
@@ -280,21 +281,21 @@ static Function &lookupFunction(Module &M, StringRef Name) {
}
TEST(LazyCallGraphTest, BasicGraphMutation) {
- std::unique_ptr<Module> M = parseAssembly(
- "define void @a() {\n"
- "entry:\n"
- " call void @b()\n"
- " call void @c()\n"
- " ret void\n"
- "}\n"
- "define void @b() {\n"
- "entry:\n"
- " ret void\n"
- "}\n"
- "define void @c() {\n"
- "entry:\n"
- " ret void\n"
- "}\n");
+ LLVMContext Context;
+ std::unique_ptr<Module> M = parseAssembly(Context, "define void @a() {\n"
+ "entry:\n"
+ " call void @b()\n"
+ " call void @c()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b() {\n"
+ "entry:\n"
+ " ret void\n"
+ "}\n"
+ "define void @c() {\n"
+ "entry:\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
LazyCallGraph::Node &A = CG.get(lookupFunction(*M, "a"));
@@ -328,7 +329,8 @@ TEST(LazyCallGraphTest, BasicGraphMutation) {
}
TEST(LazyCallGraphTest, InnerSCCFormation) {
- std::unique_ptr<Module> M = parseAssembly(DiamondOfTriangles);
+ LLVMContext Context;
+ std::unique_ptr<Module> M = parseAssembly(Context, DiamondOfTriangles);
LazyCallGraph CG(*M);
// Now mutate the graph to connect every node into a single RefSCC to ensure
@@ -391,37 +393,37 @@ TEST(LazyCallGraphTest, InnerSCCFormation) {
}
TEST(LazyCallGraphTest, MultiArmSCC) {
+ LLVMContext Context;
// Two interlocking cycles. The really useful thing about this SCC is that it
// will require Tarjan's DFS to backtrack and finish processing all of the
// children of each node in the SCC. Since this involves call edges, both
// Tarjan implementations will have to successfully navigate the structure.
- std::unique_ptr<Module> M = parseAssembly(
- "define void @f1() {\n"
- "entry:\n"
- " call void @f2()\n"
- " call void @f4()\n"
- " ret void\n"
- "}\n"
- "define void @f2() {\n"
- "entry:\n"
- " call void @f3()\n"
- " ret void\n"
- "}\n"
- "define void @f3() {\n"
- "entry:\n"
- " call void @f1()\n"
- " ret void\n"
- "}\n"
- "define void @f4() {\n"
- "entry:\n"
- " call void @f5()\n"
- " ret void\n"
- "}\n"
- "define void @f5() {\n"
- "entry:\n"
- " call void @f1()\n"
- " ret void\n"
- "}\n");
+ std::unique_ptr<Module> M = parseAssembly(Context, "define void @f1() {\n"
+ "entry:\n"
+ " call void @f2()\n"
+ " call void @f4()\n"
+ " ret void\n"
+ "}\n"
+ "define void @f2() {\n"
+ "entry:\n"
+ " call void @f3()\n"
+ " ret void\n"
+ "}\n"
+ "define void @f3() {\n"
+ "entry:\n"
+ " call void @f1()\n"
+ " ret void\n"
+ "}\n"
+ "define void @f4() {\n"
+ "entry:\n"
+ " call void @f5()\n"
+ " ret void\n"
+ "}\n"
+ "define void @f5() {\n"
+ "entry:\n"
+ " call void @f1()\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -451,27 +453,27 @@ TEST(LazyCallGraphTest, MultiArmSCC) {
}
TEST(LazyCallGraphTest, OutgoingEdgeMutation) {
- std::unique_ptr<Module> M = parseAssembly(
- "define void @a() {\n"
- "entry:\n"
- " call void @b()\n"
- " call void @c()\n"
- " ret void\n"
- "}\n"
- "define void @b() {\n"
- "entry:\n"
- " call void @d()\n"
- " ret void\n"
- "}\n"
- "define void @c() {\n"
- "entry:\n"
- " call void @d()\n"
- " ret void\n"
- "}\n"
- "define void @d() {\n"
- "entry:\n"
- " ret void\n"
- "}\n");
+ LLVMContext Context;
+ std::unique_ptr<Module> M = parseAssembly(Context, "define void @a() {\n"
+ "entry:\n"
+ " call void @b()\n"
+ " call void @c()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b() {\n"
+ "entry:\n"
+ " call void @d()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c() {\n"
+ "entry:\n"
+ " call void @d()\n"
+ " ret void\n"
+ "}\n"
+ "define void @d() {\n"
+ "entry:\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -575,6 +577,7 @@ TEST(LazyCallGraphTest, OutgoingEdgeMutation) {
}
TEST(LazyCallGraphTest, IncomingEdgeInsertion) {
+ LLVMContext Context;
// We want to ensure we can add edges even across complex diamond graphs, so
// we use the diamond of triangles graph defined above. The ascii diagram is
// repeated here for easy reference.
@@ -591,7 +594,7 @@ TEST(LazyCallGraphTest, IncomingEdgeInsertion) {
// / \ |
// a3--a2 |
//
- std::unique_ptr<Module> M = parseAssembly(DiamondOfTriangles);
+ std::unique_ptr<Module> M = parseAssembly(Context, DiamondOfTriangles);
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -668,9 +671,10 @@ TEST(LazyCallGraphTest, IncomingEdgeInsertion) {
}
TEST(LazyCallGraphTest, IncomingEdgeInsertionMidTraversal) {
+ LLVMContext Context;
// This is the same fundamental test as the previous, but we perform it
// having only partially walked the RefSCCs of the graph.
- std::unique_ptr<Module> M = parseAssembly(DiamondOfTriangles);
+ std::unique_ptr<Module> M = parseAssembly(Context, DiamondOfTriangles);
LazyCallGraph CG(*M);
// Walk the RefSCCs until we find the one containing 'c1'.
@@ -744,22 +748,22 @@ TEST(LazyCallGraphTest, IncomingEdgeInsertionMidTraversal) {
}
TEST(LazyCallGraphTest, InternalEdgeMutation) {
- std::unique_ptr<Module> M = parseAssembly(
- "define void @a() {\n"
- "entry:\n"
- " call void @b()\n"
- " ret void\n"
- "}\n"
- "define void @b() {\n"
- "entry:\n"
- " call void @c()\n"
- " ret void\n"
- "}\n"
- "define void @c() {\n"
- "entry:\n"
- " call void @a()\n"
- " ret void\n"
- "}\n");
+ LLVMContext Context;
+ std::unique_ptr<Module> M = parseAssembly(Context, "define void @a() {\n"
+ "entry:\n"
+ " call void @b()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b() {\n"
+ "entry:\n"
+ " call void @c()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c() {\n"
+ "entry:\n"
+ " call void @a()\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -824,29 +828,30 @@ TEST(LazyCallGraphTest, InternalEdgeMutation) {
}
TEST(LazyCallGraphTest, InternalEdgeRemoval) {
+ LLVMContext Context;
// A nice fully connected (including self-edges) RefSCC.
std::unique_ptr<Module> M = parseAssembly(
- "define void @a(i8** %ptr) {\n"
- "entry:\n"
- " store i8* bitcast (void(i8**)* @a to i8*), i8** %ptr\n"
- " store i8* bitcast (void(i8**)* @b to i8*), i8** %ptr\n"
- " store i8* bitcast (void(i8**)* @c to i8*), i8** %ptr\n"
- " ret void\n"
- "}\n"
- "define void @b(i8** %ptr) {\n"
- "entry:\n"
- " store i8* bitcast (void(i8**)* @a to i8*), i8** %ptr\n"
- " store i8* bitcast (void(i8**)* @b to i8*), i8** %ptr\n"
- " store i8* bitcast (void(i8**)* @c to i8*), i8** %ptr\n"
- " ret void\n"
- "}\n"
- "define void @c(i8** %ptr) {\n"
- "entry:\n"
- " store i8* bitcast (void(i8**)* @a to i8*), i8** %ptr\n"
- " store i8* bitcast (void(i8**)* @b to i8*), i8** %ptr\n"
- " store i8* bitcast (void(i8**)* @c to i8*), i8** %ptr\n"
- " ret void\n"
- "}\n");
+ Context, "define void @a(i8** %ptr) {\n"
+ "entry:\n"
+ " store i8* bitcast (void(i8**)* @a to i8*), i8** %ptr\n"
+ " store i8* bitcast (void(i8**)* @b to i8*), i8** %ptr\n"
+ " store i8* bitcast (void(i8**)* @c to i8*), i8** %ptr\n"
+ " ret void\n"
+ "}\n"
+ "define void @b(i8** %ptr) {\n"
+ "entry:\n"
+ " store i8* bitcast (void(i8**)* @a to i8*), i8** %ptr\n"
+ " store i8* bitcast (void(i8**)* @b to i8*), i8** %ptr\n"
+ " store i8* bitcast (void(i8**)* @c to i8*), i8** %ptr\n"
+ " ret void\n"
+ "}\n"
+ "define void @c(i8** %ptr) {\n"
+ "entry:\n"
+ " store i8* bitcast (void(i8**)* @a to i8*), i8** %ptr\n"
+ " store i8* bitcast (void(i8**)* @b to i8*), i8** %ptr\n"
+ " store i8* bitcast (void(i8**)* @c to i8*), i8** %ptr\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -882,29 +887,29 @@ TEST(LazyCallGraphTest, InternalEdgeRemoval) {
}
TEST(LazyCallGraphTest, InternalCallEdgeToRef) {
+ LLVMContext Context;
// A nice fully connected (including self-edges) SCC (and RefSCC)
- std::unique_ptr<Module> M = parseAssembly(
- "define void @a() {\n"
- "entry:\n"
- " call void @a()\n"
- " call void @b()\n"
- " call void @c()\n"
- " ret void\n"
- "}\n"
- "define void @b() {\n"
- "entry:\n"
- " call void @a()\n"
- " call void @b()\n"
- " call void @c()\n"
- " ret void\n"
- "}\n"
- "define void @c() {\n"
- "entry:\n"
- " call void @a()\n"
- " call void @b()\n"
- " call void @c()\n"
- " ret void\n"
- "}\n");
+ std::unique_ptr<Module> M = parseAssembly(Context, "define void @a() {\n"
+ "entry:\n"
+ " call void @a()\n"
+ " call void @b()\n"
+ " call void @c()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b() {\n"
+ "entry:\n"
+ " call void @a()\n"
+ " call void @b()\n"
+ " call void @c()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c() {\n"
+ "entry:\n"
+ " call void @a()\n"
+ " call void @b()\n"
+ " call void @c()\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -964,33 +969,34 @@ TEST(LazyCallGraphTest, InternalCallEdgeToRef) {
}
TEST(LazyCallGraphTest, InternalRefEdgeToCall) {
+ LLVMContext Context;
// Basic tests for making a ref edge a call. This hits the basics of the
// process only.
- std::unique_ptr<Module> M = parseAssembly(
- "define void @a() {\n"
- "entry:\n"
- " call void @b()\n"
- " call void @c()\n"
- " store void()* @d, void()** undef\n"
- " ret void\n"
- "}\n"
- "define void @b() {\n"
- "entry:\n"
- " store void()* @c, void()** undef\n"
- " call void @d()\n"
- " ret void\n"
- "}\n"
- "define void @c() {\n"
- "entry:\n"
- " store void()* @b, void()** undef\n"
- " call void @d()\n"
- " ret void\n"
- "}\n"
- "define void @d() {\n"
- "entry:\n"
- " store void()* @a, void()** undef\n"
- " ret void\n"
- "}\n");
+ std::unique_ptr<Module> M =
+ parseAssembly(Context, "define void @a() {\n"
+ "entry:\n"
+ " call void @b()\n"
+ " call void @c()\n"
+ " store void()* @d, void()** undef\n"
+ " ret void\n"
+ "}\n"
+ "define void @b() {\n"
+ "entry:\n"
+ " store void()* @c, void()** undef\n"
+ " call void @d()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c() {\n"
+ "entry:\n"
+ " store void()* @b, void()** undef\n"
+ " call void @d()\n"
+ " ret void\n"
+ "}\n"
+ "define void @d() {\n"
+ "entry:\n"
+ " store void()* @a, void()** undef\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -1049,59 +1055,60 @@ TEST(LazyCallGraphTest, InternalRefEdgeToCall) {
}
TEST(LazyCallGraphTest, InternalRefEdgeToCallNoCycleInterleaved) {
+ LLVMContext Context;
// Test for having a post-order prior to changing a ref edge to a call edge
// with SCCs connecting to the source and connecting to the target, but not
// connecting to both, interleaved between the source and target. This
// ensures we correctly partition the range rather than simply moving one or
// the other.
- std::unique_ptr<Module> M = parseAssembly(
- "define void @a() {\n"
- "entry:\n"
- " call void @b1()\n"
- " call void @c1()\n"
- " ret void\n"
- "}\n"
- "define void @b1() {\n"
- "entry:\n"
- " call void @c1()\n"
- " call void @b2()\n"
- " ret void\n"
- "}\n"
- "define void @c1() {\n"
- "entry:\n"
- " call void @b2()\n"
- " call void @c2()\n"
- " ret void\n"
- "}\n"
- "define void @b2() {\n"
- "entry:\n"
- " call void @c2()\n"
- " call void @b3()\n"
- " ret void\n"
- "}\n"
- "define void @c2() {\n"
- "entry:\n"
- " call void @b3()\n"
- " call void @c3()\n"
- " ret void\n"
- "}\n"
- "define void @b3() {\n"
- "entry:\n"
- " call void @c3()\n"
- " call void @d()\n"
- " ret void\n"
- "}\n"
- "define void @c3() {\n"
- "entry:\n"
- " store void()* @b1, void()** undef\n"
- " call void @d()\n"
- " ret void\n"
- "}\n"
- "define void @d() {\n"
- "entry:\n"
- " store void()* @a, void()** undef\n"
- " ret void\n"
- "}\n");
+ std::unique_ptr<Module> M =
+ parseAssembly(Context, "define void @a() {\n"
+ "entry:\n"
+ " call void @b1()\n"
+ " call void @c1()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b1() {\n"
+ "entry:\n"
+ " call void @c1()\n"
+ " call void @b2()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c1() {\n"
+ "entry:\n"
+ " call void @b2()\n"
+ " call void @c2()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b2() {\n"
+ "entry:\n"
+ " call void @c2()\n"
+ " call void @b3()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c2() {\n"
+ "entry:\n"
+ " call void @b3()\n"
+ " call void @c3()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b3() {\n"
+ "entry:\n"
+ " call void @c3()\n"
+ " call void @d()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c3() {\n"
+ "entry:\n"
+ " store void()* @b1, void()** undef\n"
+ " call void @d()\n"
+ " ret void\n"
+ "}\n"
+ "define void @d() {\n"
+ "entry:\n"
+ " store void()* @a, void()** undef\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
@@ -1163,6 +1170,7 @@ TEST(LazyCallGraphTest, InternalRefEdgeToCallNoCycleInterleaved) {
}
TEST(LazyCallGraphTest, InternalRefEdgeToCallBothPartitionAndMerge) {
+ LLVMContext Context;
// Test for having a postorder where between the source and target are all
// three kinds of other SCCs:
// 1) One connected to the target only that have to be shifted below the
@@ -1190,47 +1198,47 @@ TEST(LazyCallGraphTest, InternalRefEdgeToCallBothPartitionAndMerge) {
// G | G |
//
// And we form a cycle by connecting F to B.
- std::unique_ptr<Module> M = parseAssembly(
- "define void @a() {\n"
- "entry:\n"
- " call void @b()\n"
- " call void @e()\n"
- " ret void\n"
- "}\n"
- "define void @b() {\n"
- "entry:\n"
- " call void @c()\n"
- " call void @d()\n"
- " ret void\n"
- "}\n"
- "define void @c() {\n"
- "entry:\n"
- " call void @d()\n"
- " call void @g()\n"
- " ret void\n"
- "}\n"
- "define void @d() {\n"
- "entry:\n"
- " call void @e()\n"
- " call void @f()\n"
- " ret void\n"
- "}\n"
- "define void @e() {\n"
- "entry:\n"
- " call void @f()\n"
- " ret void\n"
- "}\n"
- "define void @f() {\n"
- "entry:\n"
- " store void()* @b, void()** undef\n"
- " call void @g()\n"
- " ret void\n"
- "}\n"
- "define void @g() {\n"
- "entry:\n"
- " store void()* @a, void()** undef\n"
- " ret void\n"
- "}\n");
+ std::unique_ptr<Module> M =
+ parseAssembly(Context, "define void @a() {\n"
+ "entry:\n"
+ " call void @b()\n"
+ " call void @e()\n"
+ " ret void\n"
+ "}\n"
+ "define void @b() {\n"
+ "entry:\n"
+ " call void @c()\n"
+ " call void @d()\n"
+ " ret void\n"
+ "}\n"
+ "define void @c() {\n"
+ "entry:\n"
+ " call void @d()\n"
+ " call void @g()\n"
+ " ret void\n"
+ "}\n"
+ "define void @d() {\n"
+ "entry:\n"
+ " call void @e()\n"
+ " call void @f()\n"
+ " ret void\n"
+ "}\n"
+ "define void @e() {\n"
+ "entry:\n"
+ " call void @f()\n"
+ " ret void\n"
+ "}\n"
+ "define void @f() {\n"
+ "entry:\n"
+ " store void()* @b, void()** undef\n"
+ " call void @g()\n"
+ " ret void\n"
+ "}\n"
+ "define void @g() {\n"
+ "entry:\n"
+ " store void()* @a, void()** undef\n"
+ " ret void\n"
+ "}\n");
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
diff --git a/llvm/unittests/Analysis/LoopPassManagerTest.cpp b/llvm/unittests/Analysis/LoopPassManagerTest.cpp
index 8a620499a3e..3cbe203e14d 100644
--- a/llvm/unittests/Analysis/LoopPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/LoopPassManagerTest.cpp
@@ -99,39 +99,39 @@ public:
static StringRef name() { return "TestLoopInvalidatingPass"; }
};
-std::unique_ptr<Module> parseIR(const char *IR) {
- LLVMContext &C = getGlobalContext();
+std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
SMDiagnostic Err;
return parseAssemblyString(IR, Err, C);
}
class LoopPassManagerTest : public ::testing::Test {
protected:
+ LLVMContext Context;
std::unique_ptr<Module> M;
public:
LoopPassManagerTest()
- : M(parseIR("define void @f() {\n"
- "entry:\n"
- " br label %loop.0\n"
- "loop.0:\n"
- " br i1 undef, label %loop.0.0, label %end\n"
- "loop.0.0:\n"
- " br i1 undef, label %loop.0.0, label %loop.0.1\n"
- "loop.0.1:\n"
- " br i1 undef, label %loop.0.1, label %loop.0\n"
- "end:\n"
- " ret void\n"
- "}\n"
- "\n"
- "define void @g() {\n"
- "entry:\n"
- " br label %loop.g.0\n"
- "loop.g.0:\n"
- " br i1 undef, label %loop.g.0, label %end\n"
- "end:\n"
- " ret void\n"
- "}\n")) {}
+ : M(parseIR(Context, "define void @f() {\n"
+ "entry:\n"
+ " br label %loop.0\n"
+ "loop.0:\n"
+ " br i1 undef, label %loop.0.0, label %end\n"
+ "loop.0.0:\n"
+ " br i1 undef, label %loop.0.0, label %loop.0.1\n"
+ "loop.0.1:\n"
+ " br i1 undef, label %loop.0.1, label %loop.0\n"
+ "end:\n"
+ " ret void\n"
+ "}\n"
+ "\n"
+ "define void @g() {\n"
+ "entry:\n"
+ " br label %loop.g.0\n"
+ "loop.g.0:\n"
+ " br i1 undef, label %loop.g.0, label %end\n"
+ "end:\n"
+ " ret void\n"
+ "}\n")) {}
};
#define EXPECT_N_ELEMENTS_EQ(N, EXPECTED, ACTUAL) \
diff --git a/llvm/unittests/Analysis/UnrollAnalyzer.cpp b/llvm/unittests/Analysis/UnrollAnalyzer.cpp
index 15d500a30c8..83d57f52469 100644
--- a/llvm/unittests/Analysis/UnrollAnalyzer.cpp
+++ b/llvm/unittests/Analysis/UnrollAnalyzer.cpp
@@ -60,11 +60,11 @@ struct UnrollAnalyzerTest : public FunctionPass {
char UnrollAnalyzerTest::ID = 0;
-std::unique_ptr<Module> makeLLVMModule(UnrollAnalyzerTest *P,
+std::unique_ptr<Module> makeLLVMModule(LLVMContext &Context,
+ UnrollAnalyzerTest *P,
const char *ModuleStr) {
- LLVMContext &C = getGlobalContext();
SMDiagnostic Err;
- return parseAssemblyString(ModuleStr, Err, C);
+ return parseAssemblyString(ModuleStr, Err, Context);
}
TEST(UnrollAnalyzerTest, BasicSimplifications) {
@@ -86,7 +86,8 @@ TEST(UnrollAnalyzerTest, BasicSimplifications) {
" ret i64 %x.lcssa\n"
"}\n";
UnrollAnalyzerTest *P = new UnrollAnalyzerTest();
- std::unique_ptr<Module> M = makeLLVMModule(P, ModuleStr);
+ LLVMContext Context;
+ std::unique_ptr<Module> M = makeLLVMModule(Context, P, ModuleStr);
legacy::PassManager Passes;
Passes.add(P);
Passes.run(*M);
@@ -148,7 +149,8 @@ TEST(UnrollAnalyzerTest, OuterLoopSimplification) {
"}\n";
UnrollAnalyzerTest *P = new UnrollAnalyzerTest();
- std::unique_ptr<Module> M = makeLLVMModule(P, ModuleStr);
+ LLVMContext Context;
+ std::unique_ptr<Module> M = makeLLVMModule(Context, P, ModuleStr);
legacy::PassManager Passes;
Passes.add(P);
Passes.run(*M);
@@ -188,7 +190,8 @@ TEST(UnrollAnalyzerTest, CmpSimplifications) {
" ret void\n"
"}\n";
UnrollAnalyzerTest *P = new UnrollAnalyzerTest();
- std::unique_ptr<Module> M = makeLLVMModule(P, ModuleStr);
+ LLVMContext Context;
+ std::unique_ptr<Module> M = makeLLVMModule(Context, P, ModuleStr);
legacy::PassManager Passes;
Passes.add(P);
Passes.run(*M);
@@ -234,7 +237,8 @@ TEST(UnrollAnalyzerTest, PtrCmpSimplifications) {
" ret void\n"
"}\n";
UnrollAnalyzerTest *P = new UnrollAnalyzerTest();
- std::unique_ptr<Module> M = makeLLVMModule(P, ModuleStr);
+ LLVMContext Context;
+ std::unique_ptr<Module> M = makeLLVMModule(Context, P, ModuleStr);
legacy::PassManager Passes;
Passes.add(P);
Passes.run(*M);
@@ -279,7 +283,8 @@ TEST(UnrollAnalyzerTest, CastSimplifications) {
"}\n";
UnrollAnalyzerTest *P = new UnrollAnalyzerTest();
- std::unique_ptr<Module> M = makeLLVMModule(P, ModuleStr);
+ LLVMContext Context;
+ std::unique_ptr<Module> M = makeLLVMModule(Context, P, ModuleStr);
legacy::PassManager Passes;
Passes.add(P);
Passes.run(*M);
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index 3af856ea203..f429c3b9914 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -25,7 +25,7 @@ class MatchSelectPatternTest : public testing::Test {
protected:
void parseAssembly(const char *Assembly) {
SMDiagnostic Error;
- M = parseAssemblyString(Assembly, Error, getGlobalContext());
+ M = parseAssemblyString(Assembly, Error, Context);
std::string errMsg;
raw_string_ostream os(errMsg);
@@ -59,6 +59,7 @@ protected:
EXPECT_EQ(P.Ordered, R.Ordered);
}
+ LLVMContext Context;
std::unique_ptr<Module> M;
Instruction *A, *B;
};
OpenPOWER on IntegriCloud