X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FExecutionEngine%2FJIT%2FJITTest.cpp;h=817d207c2dca9d49afe5936779d6e05a59d446dd;hb=7ad7c75048eb32f95eae04847908793e0183802f;hp=47907e1935ce1bdc073281d7069e94c6b9e7c69d;hpb=bc65a8d518ebe0408deb15d9314fd2ff5cbd0686;p=oota-llvm.git diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp index 47907e1935c..817d207c2dc 100644 --- a/unittests/ExecutionEngine/JIT/JITTest.cpp +++ b/unittests/ExecutionEngine/JIT/JITTest.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/ExecutionEngine/JIT.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/AsmParser/Parser.h" #include "llvm/Bitcode/ReaderWriter.h" @@ -52,7 +51,8 @@ extern "C" int32_t JITTest_AvailableExternallyFunction() { namespace { // Tests on ARM, PowerPC and SystemZ disabled as we're running the old jit -#if !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__) +#if !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__) \ + && !defined(__aarch64__) Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { std::vector params; @@ -76,7 +76,8 @@ std::string DumpFunction(const Function *F) { } class RecordingJITMemoryManager : public JITMemoryManager { - const OwningPtr Base; + const std::unique_ptr Base; + public: RecordingJITMemoryManager() : Base(JITMemoryManager::CreateDefaultMemManager()) { @@ -113,8 +114,8 @@ public: return Result; } int stubsAllocated; - virtual uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize, - unsigned Alignment) { + uint8_t *allocateStub(const GlobalValue *F, unsigned StubSize, + unsigned Alignment) override { stubsAllocated++; return Base->allocateStub(F, StubSize, Alignment); } @@ -168,7 +169,7 @@ public: bool LoadAssemblyInto(Module *M, const char *assembly) { SMDiagnostic Error; bool success = - NULL != ParseAssemblyString(assembly, M, Error, M->getContext()); + nullptr != ParseAssemblyString(assembly, M, Error, M->getContext()); std::string errMsg; raw_string_ostream os(errMsg); Error.print("", os); @@ -192,7 +193,7 @@ class JITTest : public testing::Test { .setJITMemoryManager(RJMM) .setErrorStr(&Error) .setTargetOptions(Options).create()); - ASSERT_TRUE(TheJIT.get() != NULL) << Error; + ASSERT_TRUE(TheJIT.get() != nullptr) << Error; } void LoadAssembly(const char *assembly) { @@ -202,7 +203,7 @@ class JITTest : public testing::Test { LLVMContext Context; Module *M; // Owned by ExecutionEngine. RecordingJITMemoryManager *RJMM; - OwningPtr TheJIT; + std::unique_ptr TheJIT; }; // Regression test for a bug. The JIT used to allocate globals inside the same @@ -219,13 +220,13 @@ TEST(JIT, GlobalInFunction) { // memory is more easily tested. MemMgr->setPoisonMemory(true); std::string Error; - OwningPtr JIT(EngineBuilder(M) - .setEngineKind(EngineKind::JIT) - .setErrorStr(&Error) - .setJITMemoryManager(MemMgr) - // The next line enables the fix: - .setAllocateGVsWithCode(false) - .create()); + std::unique_ptr JIT(EngineBuilder(M) + .setEngineKind(EngineKind::JIT) + .setErrorStr(&Error) + .setJITMemoryManager(MemMgr) + // The next line enables the fix: + .setAllocateGVsWithCode(false) + .create()); ASSERT_EQ(Error, ""); // Create a global variable. @@ -248,7 +249,7 @@ TEST(JIT, GlobalInFunction) { // Since F1 was codegen'd, a pointer to G should be available. int32_t *GPtr = (int32_t*)JIT->getPointerToGlobalIfAvailable(G); - ASSERT_NE((int32_t*)NULL, GPtr); + ASSERT_NE((int32_t*)nullptr, GPtr); EXPECT_EQ(0, *GPtr); // F1() should increment G. @@ -438,7 +439,7 @@ TEST_F(JITTest, ModuleDeletion) { // too far away to call directly. This #if can probably be removed when // http://llvm.org/PR5201 is fixed. #if !defined(__arm__) && !defined(__mips__) && \ - !defined(__powerpc__) && !defined(__ppc__) + !defined(__powerpc__) && !defined(__ppc__) && !defined(__aarch64__) typedef int (*FooPtr) (); TEST_F(JITTest, NoStubs) { @@ -514,7 +515,7 @@ TEST_F(JITTest, FunctionPointersOutliveTheirCreator) { // ARM does not have an implementation of replaceMachineCodeForFunction(), // so recompileAndRelinkFunction doesn't work. -#if !defined(__arm__) +#if !defined(__arm__) && !defined(__aarch64__) TEST_F(JITTest, FunctionIsRecompiledAndRelinked) { Function *F = Function::Create(TypeBuilder::get(Context), GlobalValue::ExternalLinkage, "test", M); @@ -631,22 +632,23 @@ ExecutionEngine *getJITFromBitcode( // c_str() is null-terminated like MemoryBuffer::getMemBuffer requires. MemoryBuffer *BitcodeBuffer = MemoryBuffer::getMemBuffer(Bitcode, "Bitcode for test"); - std::string errMsg; - M = getLazyBitcodeModule(BitcodeBuffer, Context, &errMsg); - if (M == NULL) { - ADD_FAILURE() << errMsg; + ErrorOr ModuleOrErr = getLazyBitcodeModule(BitcodeBuffer, Context); + if (std::error_code EC = ModuleOrErr.getError()) { + ADD_FAILURE() << EC.message(); delete BitcodeBuffer; - return NULL; + return nullptr; } + M = ModuleOrErr.get(); + std::string errMsg; ExecutionEngine *TheJIT = EngineBuilder(M) .setEngineKind(EngineKind::JIT) .setErrorStr(&errMsg) .create(); - if (TheJIT == NULL) { + if (TheJIT == nullptr) { ADD_FAILURE() << errMsg; delete M; - M = NULL; - return NULL; + M = nullptr; + return nullptr; } return TheJIT; } @@ -667,7 +669,8 @@ TEST(LazyLoadedJITTest, MaterializableAvailableExternallyFunctionIsntCompiled) { "} "); ASSERT_FALSE(Bitcode.empty()) << "Assembling failed"; Module *M; - OwningPtr TheJIT(getJITFromBitcode(Context, Bitcode, M)); + std::unique_ptr TheJIT( + getJITFromBitcode(Context, Bitcode, M)); ASSERT_TRUE(TheJIT.get()) << "Failed to create JIT."; TheJIT->DisableLazyCompilation(true); @@ -706,7 +709,8 @@ TEST(LazyLoadedJITTest, EagerCompiledRecursionThroughGhost) { "} "); ASSERT_FALSE(Bitcode.empty()) << "Assembling failed"; Module *M; - OwningPtr TheJIT(getJITFromBitcode(Context, Bitcode, M)); + std::unique_ptr TheJIT( + getJITFromBitcode(Context, Bitcode, M)); ASSERT_TRUE(TheJIT.get()) << "Failed to create JIT."; TheJIT->DisableLazyCompilation(true);