Reverse the unload order, from derived to fundamental.

Else all GlobalValues from Decls from thus Transaction will be undefined, because unloading the Decl will remove the GlobalValue.
This commit is contained in:
Axel Naumann 2016-09-07 12:25:30 +02:00 committed by sftnight
parent e1b6ce53fa
commit bb142011b4

View File

@ -97,11 +97,30 @@ namespace cling {
}
bool TransactionUnloader::RevertTransaction(Transaction* T) {
DeclUnloader DeclU(m_Sema, m_CodeGen, T);
bool Successful = unloadDeclarations(T, DeclU);
Successful = unloadFromPreprocessor(T, DeclU) && Successful;
bool Successful = true;
if (getExecutor() && T->getModule()) {
Successful = getExecutor()->unloadFromJIT(T->getModule(),
T->getExeUnloadHandle())
&& Successful;
// Cleanup the module from unused global values.
// if (T->getModule()) {
// llvm::ModulePass* globalDCE = llvm::createGlobalDCEPass();
// globalDCE->runOnModule(*T->getModule());
// }
Successful = unloadModule(T->getModule()) && Successful;
}
// Clean up the pending instantiations
m_Sema->PendingInstantiations.clear();
m_Sema->PendingLocalImplicitInstantiations.clear();
DeclUnloader DeclU(m_Sema, m_CodeGen, T);
Successful = unloadDeclarations(T, DeclU) && Successful;
Successful = unloadDeserializedDeclarations(T, DeclU) && Successful;
Successful = unloadFromPreprocessor(T, DeclU) && Successful;
#ifndef NDEBUG
//FIXME: Move the nested transaction marker out of the decl lists and
@ -111,23 +130,6 @@ namespace cling {
// assert (!DeclSize && "No parsed decls must happen in parse for module");
#endif
// Clean up the pending instantiations
m_Sema->PendingInstantiations.clear();
m_Sema->PendingLocalImplicitInstantiations.clear();
// Cleanup the module from unused global values.
// if (T->getModule()) {
// llvm::ModulePass* globalDCE = llvm::createGlobalDCEPass();
// globalDCE->runOnModule(*T->getModule());
// }
if (getExecutor() && T->getModule()) {
Successful = getExecutor()->unloadFromJIT(T->getModule(),
T->getExeUnloadHandle())
&& Successful;
Successful = unloadModule(T->getModule()) && Successful;
}
if (Successful)
T->setState(Transaction::kRolledBack);
else