Simplify JIT unit test #ifdefs

Several platforms need to disable all old-JIT unit tests, since they only
support the new MCJIT.  This currently done via #ifdef'ing out those tests
in the ExecutionEngine/JIT/*.cpp files.  As those #ifdef's have grown
historically, we now have a number of repeated directives which -in total-
cover nearly the whole file, but leave a couple of helper functions out.
When building the tests with clang itself, those helper functions now
cause spurious "unused function" warnings.

To fix those warnings, and also to remove the duplicate #ifdef conditions
and make it easier to disable the tests for a new target, this patch
consolidates the #ifdefs into a single one per file, which covers all
the tests including all helper routines.

Tested on PowerPC and SystemZ.

llvm-svn: 181200
This commit is contained in:
Ulrich Weigand 2013-05-06 16:10:35 +00:00
parent cf8ea44a83
commit f1c3004528
2 changed files with 10 additions and 28 deletions

View File

@ -35,6 +35,9 @@ using namespace llvm;
namespace {
// Tests on ARM and PowerPC disabled as we're running the old jit
#if !defined(__arm__) && !defined(__powerpc__)
Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) {
std::vector<Type*> params;
FunctionType *FTy = FunctionType::get(G->getType()->getElementType(),
@ -231,9 +234,6 @@ class JITTest : public testing::Test {
OwningPtr<ExecutionEngine> TheJIT;
};
// Tests on ARM and PowerPC disabled as we're running the old jit
#if !defined(__arm__) && !defined(__powerpc__)
// Regression test for a bug. The JIT used to allocate globals inside the same
// memory block used for the function, and when the function code was freed,
// the global was left in the same place. This test allocates a function
@ -302,8 +302,6 @@ TEST(JIT, GlobalInFunction) {
EXPECT_EQ(3, *GPtr);
}
#endif // !defined(__arm__) && !defined(__powerpc__)
// Regression test for a bug. The JITEmitter wasn't checking to verify that
// it hadn't run out of space while generating the DWARF exception information
// for an emitted function.
@ -348,8 +346,6 @@ int PlusOne(int arg) {
return arg + 1;
}
// ARM and PowerPC tests disabled pending fix for PR10783.
#if !defined(__arm__) && !defined(__powerpc__)
TEST_F(JITTest, FarCallToKnownFunction) {
// x86-64 can only make direct calls to functions within 32 bits of
// the current PC. To call anything farther away, we have to load
@ -527,7 +523,6 @@ TEST_F(JITTest, ModuleDeletion) {
EXPECT_EQ(RJMM->startExceptionTableCalls.size(),
NumTablesDeallocated);
}
#endif // !defined(__arm__) && !defined(__powerpc__)
// ARM, MIPS and PPC still emit stubs for calls since the target may be
// too far away to call directly. This #if can probably be removed when
@ -573,9 +568,6 @@ TEST_F(JITTest, NoStubs) {
}
#endif // !ARM && !PPC
// Tests on ARM and PowerPC disabled as we're running the old jit
#if !defined(__arm__) && !defined(__powerpc__)
TEST_F(JITTest, FunctionPointersOutliveTheirCreator) {
TheJIT->DisableLazyCompilation(true);
LoadAssembly("define i8()* @get_foo_addr() { "
@ -610,13 +602,9 @@ TEST_F(JITTest, FunctionPointersOutliveTheirCreator) {
#endif
}
#endif //!defined(__arm__) && !defined(__powerpc__)
// Tests on ARM and PowerPC disabled as we're running the old jit
// In addition, ARM does not have an implementation
// of replaceMachineCodeForFunction(), so recompileAndRelinkFunction
// doesn't work.
#if !defined(__arm__) && !defined(__powerpc__)
// ARM does not have an implementation of replaceMachineCodeForFunction(),
// so recompileAndRelinkFunction doesn't work.
#if !defined(__arm__)
TEST_F(JITTest, FunctionIsRecompiledAndRelinked) {
Function *F = Function::Create(TypeBuilder<int(void), false>::get(Context),
GlobalValue::ExternalLinkage, "test", M);
@ -647,7 +635,7 @@ TEST_F(JITTest, FunctionIsRecompiledAndRelinked) {
EXPECT_EQ(2, OrigFPtr())
<< "The old pointer's target should now jump to the new version";
}
#endif // !defined(__arm__) && !defined(__powerpc__)
#endif // !defined(__arm__)
} // anonymous namespace
// This variable is intentionally defined differently in the statically-compiled
@ -657,9 +645,6 @@ extern "C" int32_t JITTest_AvailableExternallyGlobal;
int32_t JITTest_AvailableExternallyGlobal LLVM_ATTRIBUTE_USED = 42;
namespace {
// Tests on ARM and PowerPC disabled as we're running the old jit
#if !defined(__arm__) && !defined(__powerpc__)
TEST_F(JITTest, AvailableExternallyGlobalIsntEmitted) {
TheJIT->DisableLazyCompilation(true);
LoadAssembly("@JITTest_AvailableExternallyGlobal = "
@ -676,7 +661,6 @@ TEST_F(JITTest, AvailableExternallyGlobalIsntEmitted) {
EXPECT_EQ(42, loader()) << "func should return 42 from the external global,"
<< " not 7 from the IR version.";
}
#endif //!defined(__arm__) && !defined(__powerpc__)
} // anonymous namespace
// This function is intentionally defined differently in the statically-compiled
// program from the IR input to the JIT to assert that the JIT doesn't use its
@ -687,8 +671,6 @@ extern "C" int32_t JITTest_AvailableExternallyFunction() {
}
namespace {
// ARM and PowerPC tests disabled pending fix for PR10783.
#if !defined(__arm__) && !defined(__powerpc__)
TEST_F(JITTest, AvailableExternallyFunctionIsntCompiled) {
TheJIT->DisableLazyCompilation(true);
LoadAssembly("define available_externally i32 "

View File

@ -20,6 +20,9 @@ using namespace llvm;
namespace {
// ARM and PowerPC tests disabled pending fix for PR10783.
#if !defined(__arm__) && !defined(__powerpc__)
bool LoadAssemblyInto(Module *M, const char *assembly) {
SMDiagnostic Error;
bool success =
@ -65,9 +68,6 @@ void createModule2(LLVMContext &Context2, Module *&M2, Function *&FooF2) {
FooF2 = M2->getFunction("foo2");
}
// ARM and PowerPC tests disabled pending fix for PR10783.
#if !defined(__arm__) && !defined(__powerpc__)
TEST(MultiJitTest, EagerMode) {
LLVMContext Context1;
Module *M1 = 0;