diff options
| author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-14 21:59:01 +0000 |
|---|---|---|
| committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-14 21:59:01 +0000 |
| commit | 03b42e41bf4bdd9ab05ea4c6905bae5d19971960 (patch) | |
| tree | d4249845a564b11af673299653e7c4e876d8c4f2 /llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp | |
| parent | 3d1c1deb04efe0022f11ebc18bb43d7341ba0c75 (diff) | |
| download | llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.zip llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.tar.gz llvm-03b42e41bf4bdd9ab05ea4c6905bae5d19971960.tar.bz2 | |
Remove every uses of getGlobalContext() in LLVM (but the C API)
At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.
This is the first part of http://reviews.llvm.org/D19094
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266379
Diffstat (limited to 'llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp')
| -rw-r--r-- | llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp index 3ffa9cd..7cad841 100644 --- a/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp +++ b/llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp @@ -28,7 +28,7 @@ private: protected: ExecutionEngineTest() { - auto Owner = make_unique<Module>("<main>", getGlobalContext()); + auto Owner = make_unique<Module>("<main>", Context); M = Owner.get(); Engine.reset(EngineBuilder(std::move(Owner)).setErrorStr(&Error).create()); } @@ -44,13 +44,13 @@ protected: } std::string Error; + LLVMContext Context; Module *M; // Owned by ExecutionEngine. std::unique_ptr<ExecutionEngine> Engine; }; TEST_F(ExecutionEngineTest, ForwardGlobalMapping) { - GlobalVariable *G1 = - NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1"); + GlobalVariable *G1 = NewExtGlobal(Type::getInt32Ty(Context), "Global1"); int32_t Mem1 = 3; Engine->addGlobalMapping(G1, &Mem1); EXPECT_EQ(&Mem1, Engine->getPointerToGlobalIfAvailable(G1)); @@ -63,8 +63,7 @@ TEST_F(ExecutionEngineTest, ForwardGlobalMapping) { Engine->updateGlobalMapping(G1, &Mem2); EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1)); - GlobalVariable *G2 = - NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1"); + GlobalVariable *G2 = NewExtGlobal(Type::getInt32Ty(Context), "Global1"); EXPECT_EQ(nullptr, Engine->getPointerToGlobalIfAvailable(G2)) << "The NULL return shouldn't depend on having called" << " updateGlobalMapping(..., NULL)"; @@ -76,8 +75,7 @@ TEST_F(ExecutionEngineTest, ForwardGlobalMapping) { } TEST_F(ExecutionEngineTest, ReverseGlobalMapping) { - GlobalVariable *G1 = - NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1"); + GlobalVariable *G1 = NewExtGlobal(Type::getInt32Ty(Context), "Global1"); int32_t Mem1 = 3; Engine->addGlobalMapping(G1, &Mem1); @@ -87,8 +85,7 @@ TEST_F(ExecutionEngineTest, ReverseGlobalMapping) { EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1)); EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2)); - GlobalVariable *G2 = - NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global2"); + GlobalVariable *G2 = NewExtGlobal(Type::getInt32Ty(Context), "Global2"); Engine->updateGlobalMapping(G2, &Mem1); EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1)); EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2)); @@ -104,8 +101,7 @@ TEST_F(ExecutionEngineTest, ReverseGlobalMapping) { } TEST_F(ExecutionEngineTest, ClearModuleMappings) { - GlobalVariable *G1 = - NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1"); + GlobalVariable *G1 = NewExtGlobal(Type::getInt32Ty(Context), "Global1"); int32_t Mem1 = 3; Engine->addGlobalMapping(G1, &Mem1); @@ -115,8 +111,7 @@ TEST_F(ExecutionEngineTest, ClearModuleMappings) { EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1)); - GlobalVariable *G2 = - NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global2"); + GlobalVariable *G2 = NewExtGlobal(Type::getInt32Ty(Context), "Global2"); // After clearing the module mappings, we can assign a new GV to the // same address. Engine->addGlobalMapping(G2, &Mem1); @@ -124,8 +119,7 @@ TEST_F(ExecutionEngineTest, ClearModuleMappings) { } TEST_F(ExecutionEngineTest, DestructionRemovesGlobalMapping) { - GlobalVariable *G1 = - NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1"); + GlobalVariable *G1 = NewExtGlobal(Type::getInt32Ty(Context), "Global1"); int32_t Mem1 = 3; Engine->addGlobalMapping(G1, &Mem1); // Make sure the reverse mapping is enabled. |
