Remove code duplication.
Unload global values (global variables)

When executable code is generated from the llvm::Module the JIT stores the
GlobalValue, Address in a map. This map is used to 'lock' the GlobalValue, so
that it doesn't go out of sync. If we want to 'unload' it we first need to
update the global mapping so that the JIT/ExecutionEngine 'forgets' about the
mapping.
Make sure we don't forget the very important information.
It explains why we saw assertions while trying to replace a llvm value, with another.
Assert that the reference came from the static initializers and upgrade the test.

The compiled code is unloaded by iterating the AST out of which the compiled code
came. The problem is that C++ supports static initialization. For example:
int a = 5; on the global scope means set the value of a to 5 before the program
starts. To support that clang implicitly generates functions that enforce the
expected initialization order. That can become easily very complex. Let's see
a more "real-life" example:

int f() { printf("I am f()"); return 0; }
int a = f();

Besides the code for a and f clang will emit:
define internal void @__cxx_global_var_init() section "__TEXT,__StaticInit,regular,pure_instructions" {
entry:
  %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%"struct.cling::runtime::internal::__trigger__cxa_atexit"*)* @_ZN5cling7runtime8internal21__trigger__cxa_atexitD1Ev to void (i8*)*), i8* getelementptr inbounds (%"struct.cling::runtime::internal::__trigger__cxa_atexit"* @_ZN5cling7runtime8internal1SE, i32 0, i32 0), i8* @__dso_handle) #1
  ret void
}
define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
entry:
  call void @__cxx_global_var_init()
  ret void
}

and more importantly:

define internal void @__cxx_global_var_init1() section "__TEXT,__StaticInit,regular,pure_instructions" {
entry:
  %call = call i32 @_Z1fv() ; THAT IS A REFERENCE TO f()
  store i32 %call, i32* undef, align 4
  ret void
}

So when iterating the AST and trying to remove f(), we cannot because it is still
referenced by __cxx_global_var_init1. However we know this is not an issue,
because that __cxx_global_var_init1 was meant to be executed only once and that
already happened. So in first approximation we could drop the references of f
in __cxx_global_var_init1 and remove the rest.
Construct the mangle context upon each call.
It is cheap to construct. And makes the call independent and static-ready :)
Make the function static.
Add TODO.
Erase takes iterator and sets the wrapper fd to 0 if the wrapper is being erased.
Compile might return empty transaction, i.e transaction with no decls.

Then we should cut off interpreting early.
If the transaction contains no useful code return to the pool.

This can happen in many cases such as parsing comments for example.
Iterate in the correct, from CodeGen point of view order.
Remove the custom mangler. We should use the one in the cling::utils.
Move the GlobalValue revert logic into separate routines.
Enhance it to support reverting of the static init functions, too.
Use store/compare state for detailed verification.
maybeMangleDeclName should take GlobalDecl. This enforces integrity.
Enforce integrity of getGlobalAddress, too.
Even in cases where the transaction was empty return success.
Pick up the right ctor/dtor type.
Turn the if into an assert.
Implement visitation over the decl context.

The decl context is the 'container' of the decls either an enum, a class, a struct
an union or a namespace. We can default to it in almost all cases for reverting.