//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/JIT.h"
-#include "llvm/Assembly/Parser.h"
+#include "llvm/AsmParser/Parser.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
namespace {
-// ARM and PowerPC tests disabled pending fix for PR10783.
-#if !defined(__arm__) && !defined(__powerpc__)
+// ARM, PowerPC and SystemZ tests disabled pending fix for PR10783.
+#if !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__) \
+ && !defined(__aarch64__)
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);
TEST(MultiJitTest, EagerMode) {
LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
+ Module *M1 = nullptr;
+ Function *FooF1 = nullptr;
createModule1(Context1, M1, FooF1);
LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
+ Module *M2 = nullptr;
+ Function *FooF2 = nullptr;
createModule2(Context2, M2, FooF2);
// Now we create the JIT in eager mode
- OwningPtr<ExecutionEngine> EE1(EngineBuilder(M1).create());
+ std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(M1).create());
EE1->DisableLazyCompilation(true);
- OwningPtr<ExecutionEngine> EE2(EngineBuilder(M2).create());
+ std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(M2).create());
EE2->DisableLazyCompilation(true);
// Call the `foo' function with no arguments:
TEST(MultiJitTest, LazyMode) {
LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
+ Module *M1 = nullptr;
+ Function *FooF1 = nullptr;
createModule1(Context1, M1, FooF1);
LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
+ Module *M2 = nullptr;
+ Function *FooF2 = nullptr;
createModule2(Context2, M2, FooF2);
// Now we create the JIT in lazy mode
- OwningPtr<ExecutionEngine> EE1(EngineBuilder(M1).create());
+ std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(M1).create());
EE1->DisableLazyCompilation(false);
- OwningPtr<ExecutionEngine> EE2(EngineBuilder(M2).create());
+ std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(M2).create());
EE2->DisableLazyCompilation(false);
// Call the `foo' function with no arguments:
TEST(MultiJitTest, JitPool) {
LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
+ Module *M1 = nullptr;
+ Function *FooF1 = nullptr;
createModule1(Context1, M1, FooF1);
LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
+ Module *M2 = nullptr;
+ Function *FooF2 = nullptr;
createModule2(Context2, M2, FooF2);
// Now we create two JITs
- OwningPtr<ExecutionEngine> EE1(EngineBuilder(M1).create());
- OwningPtr<ExecutionEngine> EE2(EngineBuilder(M2).create());
+ std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(M1).create());
+ std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(M2).create());
Function *F1 = EE1->FindFunctionNamed("foo1");
void *foo1 = EE1->getPointerToFunction(F1);
EXPECT_TRUE(fa != 0);
fa = *(intptr_t *)fa; // Bound value of IAT
}
+#elif defined(__x86_64__)
+ // getPointerToNamedFunction might be indirect jump
+ // on Win32 x64 --enable-shared.
+ // FF 25 <pcrel32>: jmp *(RIP + pointer to IAT)
+ if (sa != fa && memcmp((char *)fa, "\xFF\x25", 2) == 0) {
+ fa += *(int32_t *)(fa + 2) + 6; // Address to IAT(RIP)
+ fa = *(intptr_t *)fa; // Bound value of IAT
+ }
#endif
EXPECT_TRUE(sa == fa);
}
-#endif // !defined(__arm__) && !defined(__powerpc__)
+#endif // !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__)
} // anonymous namespace