Remove unused "remap symbols".

This commit is contained in:
Axel Naumann 2015-01-28 15:56:11 +01:00 committed by sftnight
parent 8efd56133d
commit 7e2955f8de
2 changed files with 1 additions and 56 deletions

View File

@ -122,45 +122,6 @@ void IncrementalExecutor::shuttingDown() {
}
}
void IncrementalExecutor::remapSymbols() {
// Note: iteration of ++remapI happens in the body due to invalidation
// of the erased iterator!
for (auto remapI = std::begin(m_SymbolsToRemap),
remapE = std::end(m_SymbolsToRemap);
remapI != remapE;) {
// The function for which the symbol address will be replaced
llvm::Function* origFunc
= m_engine->FindFunctionNamed(remapI->first.c_str());
if (!origFunc) {
// Go to next element.
++remapI;
continue;
}
// The new symbol address, which might be NULL to signal a symbol
// lookup is required
void* replaceAddr = remapI->second.first;
if (!replaceAddr) {
// A symbol lookup is required to find the replacement address.
llvm::Function* interpFunc
= m_engine->FindFunctionNamed(remapI->second.second.c_str());
assert(interpFunc && "replacement function must exist.");
// Generate the symbol and get its address
replaceAddr = m_engine->getPointerToFunction(interpFunc);
}
assert(replaceAddr && "cannot find replacement symbol");
// Replace the mapping of function symbol to new address
m_engine->updateGlobalMapping(origFunc, replaceAddr);
// Note that the current entry was successfully remapped.
// Save the current so we can erase it *after* the iterator increment
// or we would increment an invalid iterator.
auto remapErase = remapI;
++remapI;
m_SymbolsToRemap.erase(remapErase);
}
}
void IncrementalExecutor::AddAtExitFunc(void (*func) (void*), void* arg) {
// Register a CXAAtExit function
m_AtExitFuncs.push_back(CXAAtExitElement(func, arg, m_CurrentAtExitModule));
@ -240,7 +201,6 @@ IncrementalExecutor::executeFunction(llvm::StringRef funcname,
if (returnValue) {
*returnValue = Value();
}
remapSymbols();
llvm::Function* f = m_engine->FindFunctionNamed(funcname.str().c_str());
if (!f) {
@ -330,7 +290,6 @@ IncrementalExecutor::runStaticInitializersOnce(llvm::Module* m) {
// Execute the ctor/dtor function!
if (llvm::Function *F = llvm::dyn_cast<llvm::Function>(FP)) {
remapSymbols();
m_engine->getPointerToFunction(F);
// check if there is any unresolved symbol in the list
if (diagnoseUnresolvedSymbols("static initializers"))
@ -441,7 +400,6 @@ IncrementalExecutor::getPointerToGlobalFromJIT(const llvm::GlobalValue& GV) {
// We don't care whether something was unresolved before.
m_unresolvedSymbols.clear();
remapSymbols();
if (void* addr = m_engine->getPointerToGlobalIfAvailable(&GV))
return addr;

View File

@ -51,15 +51,7 @@ namespace cling {
///
std::unique_ptr<llvm::ExecutionEngine> m_engine;
///\brief Symbols to be replaced by special Interpreter implementations.
///
/// Replaces the exectution engine's symbol "first" by second.first, or
/// if it is NULL, but the symbol second.second which must exist at the time
/// the symbol is replaced. The replacement is tried again until first us
/// found.
std::map<std::string,std::pair<void*,std::string>> m_SymbolsToRemap;
///\breif Helper that manages when the destructor of an object to be called.
///\brief Helper that manages when the destructor of an object to be called.
///
/// The object is registered first as an CXAAtExitElement and then cling
/// takes the control of it's destruction.
@ -213,11 +205,6 @@ namespace cling {
/// that can be passed to it.
void BuildEngine(std::unique_ptr<llvm::Module> m);
///\brief Remaps the __cxa_at_exit with a interpreter-controlled one, such
/// that the interpreter can call the object destructors at the right time.
///
void remapSymbols();
///\brief Report and empty m_unresolvedSymbols.
///\return true if m_unresolvedSymbols was non-empty.
bool diagnoseUnresolvedSymbols(llvm::StringRef trigger,