Skip to content

Commit

Permalink
Two improvements to FunctionMover
Browse files Browse the repository at this point in the history
- Don't crash on Functions that don't have a name set
- Ask MCJIT for GlobalVariables, not the memory manager
  • Loading branch information
Keno committed Dec 28, 2014
1 parent 3bfe8de commit fb730f3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class FunctionMover : public ValueMaterializer
return destModule->getOrInsertFunction(F->getName(),F->getFunctionType());
}
if (F->isDeclaration() || F->getParent() != destModule) {
if (F->getName().empty())
return CloneFunctionProto(F);
Function *shadow = srcModule->getFunction(F->getName());
if (shadow != NULL && !shadow->isDeclaration()) {
// Not truly external
Expand Down Expand Up @@ -220,10 +222,12 @@ class FunctionMover : public ValueMaterializer
newGV->copyAttributesFrom(GV);
if (GV->isDeclaration())
return newGV;
uint64_t addr = jl_mcjmm->getSymbolAddress(GV->getName());
if (addr != 0) {
newGV->setExternallyInitialized(true);
return newGV;
if (!GV->getName().empty()) {
uint64_t addr = jl_ExecutionEngine->getGlobalValueAddress(GV->getName());
if (addr != 0) {
newGV->setExternallyInitialized(true);
return newGV;
}
}
std::map<Value*, void *>::iterator it;
it = llvm_to_jl_value.find(GV);
Expand Down

0 comments on commit fb730f3

Please sign in to comment.