mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-22 10:16:43 +00:00
Revert "[ExecutionEngine] Use std::function rather than a function pointer for the LazyFunctionCreator."
This reverts commit r241962, as it was breaking all ARM buildbots. It also reverts the two subsequent related commits: r241974: "[ExecutionEngine] Add a static cast to the unittest for r241962 to suppress a warning." r241973: "[ExecutionEngine] Remove cruft and fix a couple of warnings in the test case for r241962." git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241983 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e3fa768c0
commit
22af148912
@ -31,7 +31,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
@ -90,8 +89,6 @@ public:
|
|||||||
uint64_t RemoveMapping(StringRef Name);
|
uint64_t RemoveMapping(StringRef Name);
|
||||||
};
|
};
|
||||||
|
|
||||||
using FunctionCreator = std::function<void *(const std::string &)>;
|
|
||||||
|
|
||||||
/// \brief Abstract interface for implementation execution of LLVM modules,
|
/// \brief Abstract interface for implementation execution of LLVM modules,
|
||||||
/// designed to support both interpreter and just-in-time (JIT) compiler
|
/// designed to support both interpreter and just-in-time (JIT) compiler
|
||||||
/// implementations.
|
/// implementations.
|
||||||
@ -150,7 +147,7 @@ protected:
|
|||||||
/// LazyFunctionCreator - If an unknown function is needed, this function
|
/// LazyFunctionCreator - If an unknown function is needed, this function
|
||||||
/// pointer is invoked to create it. If this returns null, the JIT will
|
/// pointer is invoked to create it. If this returns null, the JIT will
|
||||||
/// abort.
|
/// abort.
|
||||||
FunctionCreator LazyFunctionCreator;
|
void *(*LazyFunctionCreator)(const std::string &);
|
||||||
|
|
||||||
/// getMangledName - Get mangled name.
|
/// getMangledName - Get mangled name.
|
||||||
std::string getMangledName(const GlobalValue *GV);
|
std::string getMangledName(const GlobalValue *GV);
|
||||||
@ -473,8 +470,8 @@ public:
|
|||||||
/// InstallLazyFunctionCreator - If an unknown function is needed, the
|
/// InstallLazyFunctionCreator - If an unknown function is needed, the
|
||||||
/// specified function pointer is invoked to create it. If it returns null,
|
/// specified function pointer is invoked to create it. If it returns null,
|
||||||
/// the JIT will abort.
|
/// the JIT will abort.
|
||||||
void InstallLazyFunctionCreator(FunctionCreator C) {
|
void InstallLazyFunctionCreator(void* (*P)(const std::string &)) {
|
||||||
LazyFunctionCreator = C;
|
LazyFunctionCreator = P;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -199,68 +199,4 @@ TEST_F(MCJITTest, multiple_decl_lookups) {
|
|||||||
EXPECT_EQ(A, B) << "Repeat calls to getPointerToFunction fail.";
|
EXPECT_EQ(A, B) << "Repeat calls to getPointerToFunction fail.";
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void * (*FunctionHandlerPtr)(const std::string &str);
|
|
||||||
|
|
||||||
TEST_F(MCJITTest, lazy_function_creator_pointer) {
|
|
||||||
SKIP_UNSUPPORTED_PLATFORM;
|
|
||||||
|
|
||||||
Function *Foo = insertExternalReferenceToFunction<int32_t(void)>(M.get(),
|
|
||||||
"\1Foo");
|
|
||||||
startFunction<int32_t(void)>(M.get(), "Parent");
|
|
||||||
CallInst *Call = Builder.CreateCall(Foo, {});
|
|
||||||
Builder.CreateRet(Call);
|
|
||||||
|
|
||||||
createJIT(std::move(M));
|
|
||||||
|
|
||||||
// Set up the lazy function creator that records the name of the last
|
|
||||||
// unresolved external function found in the module. Using a function pointer
|
|
||||||
// prevents us from capturing local variables, which is why this is static.
|
|
||||||
static std::string UnresolvedExternal;
|
|
||||||
FunctionHandlerPtr UnresolvedHandler = [] (const std::string &str) {
|
|
||||||
UnresolvedExternal = str;
|
|
||||||
return (void *)(uintptr_t)-1;
|
|
||||||
};
|
|
||||||
TheJIT->InstallLazyFunctionCreator(UnresolvedHandler);
|
|
||||||
|
|
||||||
// JIT the module.
|
|
||||||
TheJIT->finalizeObject();
|
|
||||||
|
|
||||||
// Verify that our handler was called.
|
|
||||||
EXPECT_EQ(UnresolvedExternal, "Foo");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(MCJITTest, lazy_function_creator_lambda) {
|
|
||||||
SKIP_UNSUPPORTED_PLATFORM;
|
|
||||||
|
|
||||||
Function *Foo1 = insertExternalReferenceToFunction<int32_t(void)>(M.get(),
|
|
||||||
"\1Foo1");
|
|
||||||
Function *Foo2 = insertExternalReferenceToFunction<int32_t(void)>(M.get(),
|
|
||||||
"\1Foo2");
|
|
||||||
startFunction<int32_t(void)>(M.get(), "Parent");
|
|
||||||
CallInst *Call1 = Builder.CreateCall(Foo1, {});
|
|
||||||
CallInst *Call2 = Builder.CreateCall(Foo2, {});
|
|
||||||
Value *Result = Builder.CreateAdd(Call1, Call2);
|
|
||||||
Builder.CreateRet(Result);
|
|
||||||
|
|
||||||
createJIT(std::move(M));
|
|
||||||
|
|
||||||
// Set up the lazy function creator that records the name of unresolved
|
|
||||||
// external functions in the module.
|
|
||||||
std::vector<std::string> UnresolvedExternals;
|
|
||||||
auto UnresolvedHandler = [&UnresolvedExternals] (const std::string &str) {
|
|
||||||
UnresolvedExternals.push_back(str);
|
|
||||||
return (void *)(uintptr_t)-1;
|
|
||||||
};
|
|
||||||
TheJIT->InstallLazyFunctionCreator(UnresolvedHandler);
|
|
||||||
|
|
||||||
// JIT the module.
|
|
||||||
TheJIT->finalizeObject();
|
|
||||||
|
|
||||||
// Verify that our handler was called for each unresolved function.
|
|
||||||
auto I = UnresolvedExternals.begin(), E = UnresolvedExternals.end();
|
|
||||||
EXPECT_EQ(UnresolvedExternals.size(), static_cast<size_t>(2));
|
|
||||||
EXPECT_FALSE(std::find(I, E, "Foo1") == E);
|
|
||||||
EXPECT_FALSE(std::find(I, E, "Foo2") == E);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user