Skip to content
Snippets Groups Projects
Commit 3ea07b8e authored by Vassil Vassilev's avatar Vassil Vassilev
Browse files

Remove the functions after the loop is done.

parent decf9215
Branches
Tags
No related merge requests found
......@@ -238,6 +238,8 @@ IncrementalExecutor::runStaticInitializersOnce(llvm::Module* m) {
// We don't care whether something was unresolved before.
m_unresolvedSymbols.clear();
SmallVector<Function*, 2> initFuncs;
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
llvm::ConstantStruct *CS
= llvm::dyn_cast<llvm::ConstantStruct>(InitList->getOperand(i));
......@@ -274,27 +276,32 @@ IncrementalExecutor::runStaticInitializersOnce(llvm::Module* m) {
}
//executeFunction(F->getName());
m_engine->runFunction(F, std::vector<llvm::GenericValue>());
// Cleanup also the dangling init functions. They are in the form:
// define internal void @_GLOBAL__I_aN() section "..."{
// entry:
// call void @__cxx_global_var_init(N-1)()
// ret void
// }
//
// define internal void @__cxx_global_var_init(N-1)() section "..." {
// entry:
// call void @_ZN7MyClassC1Ev(%struct.MyClass* @n)
// ret void
// }
// Erase __cxx_global_var_init(N-1)() first.
Function* GlobalVarInitF =
cast<Function>(F->getEntryBlock().getFirstNonPHI()->getOperand(0));
F->eraseFromParent();
GlobalVarInitF->eraseFromParent();
initFuncs.push_back(F);
}
}
for (SmallVector<Function*,2>::iterator I = initFuncs.begin(),
E = initFuncs.end(); I != E; ++I) {
// Cleanup also the dangling init functions. They are in the form:
// define internal void @_GLOBAL__I_aN() section "..."{
// entry:
// call void @__cxx_global_var_init(N-1)()
// ret void
// }
//
// define internal void @__cxx_global_var_init(N-1)() section "..." {
// entry:
// call void @_ZN7MyClassC1Ev(%struct.MyClass* @n)
// ret void
// }
// Erase __cxx_global_var_init(N-1)() first.
Function* GlobalVarInitF =
cast<Function>((*I)->getEntryBlock().getFirstNonPHI()->getOperand(0));
(*I)->eraseFromParent();
GlobalVarInitF->eraseFromParent();
}
return kExeSuccess;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment