mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
* Disambiguate symbols before we start splitting module by functions
* Moved DisambiguateGlobalSymbols() out of the ReduceMisCodegenFunctions class * Added an assert to have a cleaner exit if `main' is not found in the module git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7380 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -41,8 +41,6 @@ public:
|
|||||||
|
|
||||||
bool TestFuncs(const std::vector<Function*> &CodegenTest,
|
bool TestFuncs(const std::vector<Function*> &CodegenTest,
|
||||||
bool KeepFiles = false);
|
bool KeepFiles = false);
|
||||||
|
|
||||||
void DisambiguateGlobalSymbols(Module *M);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +62,6 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
|||||||
for (Module::giterator I=SafeModule->gbegin(),E = SafeModule->gend();I!=E;++I)
|
for (Module::giterator I=SafeModule->gbegin(),E = SafeModule->gend();I!=E;++I)
|
||||||
I->setLinkage(GlobalValue::ExternalLinkage);
|
I->setLinkage(GlobalValue::ExternalLinkage);
|
||||||
|
|
||||||
DisambiguateGlobalSymbols(SafeModule);
|
|
||||||
Module *TestModule = CloneModule(SafeModule);
|
Module *TestModule = CloneModule(SafeModule);
|
||||||
|
|
||||||
// Make sure global initializers exist only in the safe module (CBE->.so)
|
// Make sure global initializers exist only in the safe module (CBE->.so)
|
||||||
@@ -75,6 +72,7 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
|||||||
for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
|
||||||
Function *TNOF = SafeModule->getFunction(Funcs[i]->getName(),
|
Function *TNOF = SafeModule->getFunction(Funcs[i]->getName(),
|
||||||
Funcs[i]->getFunctionType());
|
Funcs[i]->getFunctionType());
|
||||||
|
DEBUG(std::cerr << "Removing function " << Funcs[i]->getName() << "\n");
|
||||||
assert(TNOF && "Function doesn't exist in module!");
|
assert(TNOF && "Function doesn't exist in module!");
|
||||||
DeleteFunctionBody(TNOF); // Function is now external in this module!
|
DeleteFunctionBody(TNOF); // Function is now external in this module!
|
||||||
}
|
}
|
||||||
@@ -96,6 +94,7 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
|
|||||||
if (BD.isExecutingJIT()) {
|
if (BD.isExecutingJIT()) {
|
||||||
// Must delete `main' from Safe module if it has it
|
// Must delete `main' from Safe module if it has it
|
||||||
Function *safeMain = SafeModule->getNamedFunction("main");
|
Function *safeMain = SafeModule->getNamedFunction("main");
|
||||||
|
assert(safeMain && "`main' function not found in safe module!");
|
||||||
DeleteFunctionBody(safeMain);
|
DeleteFunctionBody(safeMain);
|
||||||
|
|
||||||
// Add an external function "getPointerToNamedFunction" that JIT provides
|
// Add an external function "getPointerToNamedFunction" that JIT provides
|
||||||
@@ -283,7 +282,7 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReduceMisCodegenFunctions::DisambiguateGlobalSymbols(Module *M) {
|
void DisambiguateGlobalSymbols(Module *M) {
|
||||||
// First, try not to cause collisions by minimizing chances of renaming an
|
// First, try not to cause collisions by minimizing chances of renaming an
|
||||||
// already-external symbol, so take in external globals and functions as-is.
|
// already-external symbol, so take in external globals and functions as-is.
|
||||||
Disambiguator D;
|
Disambiguator D;
|
||||||
@@ -317,6 +316,7 @@ bool BugDriver::debugCodeGenerator() {
|
|||||||
if (isExecutingJIT()) {
|
if (isExecutingJIT()) {
|
||||||
// Get the `main' function
|
// Get the `main' function
|
||||||
Function *oldMain = Program->getNamedFunction("main");
|
Function *oldMain = Program->getNamedFunction("main");
|
||||||
|
assert(oldMain && "`main' function not found in program!");
|
||||||
// Rename it
|
// Rename it
|
||||||
oldMain->setName("old_main");
|
oldMain->setName("old_main");
|
||||||
// Create a NEW `main' function with same type
|
// Create a NEW `main' function with same type
|
||||||
@@ -343,6 +343,8 @@ bool BugDriver::debugCodeGenerator() {
|
|||||||
BB->getInstList().push_back(ret);
|
BB->getInstList().push_back(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DisambiguateGlobalSymbols(Program);
|
||||||
|
|
||||||
// Do the reduction...
|
// Do the reduction...
|
||||||
ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions);
|
ReduceMisCodegenFunctions(*this).reduceList(MisCodegenFunctions);
|
||||||
|
|
||||||
@@ -355,4 +357,3 @@ bool BugDriver::debugCodeGenerator() {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user