mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-20 05:38:50 +00:00
Use lazy parsing in LTO. Unfortunately this is only a 3% time saving for
'ar'. Have to figure out how to make libLTO even lazier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127901 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
19f6f503d6
commit
f19d7a7af3
@ -87,6 +87,10 @@ LTOCodeGenerator::~LTOCodeGenerator()
|
|||||||
|
|
||||||
bool LTOCodeGenerator::addModule(LTOModule* mod, std::string& errMsg)
|
bool LTOCodeGenerator::addModule(LTOModule* mod, std::string& errMsg)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(mod->getLLVVMModule()->MaterializeAllPermanently(&errMsg))
|
||||||
|
return true;
|
||||||
|
|
||||||
bool ret = _linker.LinkInModule(mod->getLLVVMModule(), &errMsg);
|
bool ret = _linker.LinkInModule(mod->getLLVVMModule(), &errMsg);
|
||||||
|
|
||||||
const std::vector<const char*> &undefs = mod->getAsmUndefinedRefs();
|
const std::vector<const char*> &undefs = mod->getAsmUndefinedRefs();
|
||||||
|
@ -91,7 +91,7 @@ LTOModule *LTOModule::makeLTOModule(const char *path,
|
|||||||
errMsg = ec.message();
|
errMsg = ec.message();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return makeLTOModule(buffer.get(), errMsg);
|
return makeLTOModule(buffer.take(), errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
|
LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
|
||||||
@ -111,7 +111,7 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
|
|||||||
errMsg = ec.message();
|
errMsg = ec.message();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return makeLTOModule(buffer.get(), errMsg);
|
return makeLTOModule(buffer.take(), errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// makeBuffer - Create a MemoryBuffer from a memory range.
|
/// makeBuffer - Create a MemoryBuffer from a memory range.
|
||||||
@ -126,7 +126,7 @@ LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
|
|||||||
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
|
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return NULL;
|
return NULL;
|
||||||
return makeLTOModule(buffer.get(), errMsg);
|
return makeLTOModule(buffer.take(), errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
|
LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
|
||||||
@ -139,9 +139,12 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse bitcode buffer
|
// parse bitcode buffer
|
||||||
OwningPtr<Module> m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg));
|
OwningPtr<Module> m(getLazyBitcodeModule(buffer, getGlobalContext(),
|
||||||
if (!m)
|
&errMsg));
|
||||||
|
if (!m) {
|
||||||
|
delete buffer;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Triple = m->getTargetTriple();
|
std::string Triple = m->getTargetTriple();
|
||||||
if (Triple.empty())
|
if (Triple.empty())
|
||||||
@ -638,6 +641,18 @@ bool LTOModule::addAsmGlobalSymbols(MCContext &Context) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isDeclaration(const GlobalValue &V) {
|
||||||
|
if (V.hasAvailableExternallyLinkage())
|
||||||
|
return true;
|
||||||
|
if (V.isMaterializable())
|
||||||
|
return false;
|
||||||
|
return V.isDeclaration();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isAliasToDeclaration(const GlobalAlias &V) {
|
||||||
|
return isDeclaration(*V.getAliasedGlobal());
|
||||||
|
}
|
||||||
|
|
||||||
bool LTOModule::ParseSymbols() {
|
bool LTOModule::ParseSymbols() {
|
||||||
// Use mangler to add GlobalPrefix to names to match linker names.
|
// Use mangler to add GlobalPrefix to names to match linker names.
|
||||||
MCContext Context(*_target->getMCAsmInfo(), NULL);
|
MCContext Context(*_target->getMCAsmInfo(), NULL);
|
||||||
@ -645,7 +660,7 @@ bool LTOModule::ParseSymbols() {
|
|||||||
|
|
||||||
// add functions
|
// add functions
|
||||||
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
|
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
|
||||||
if (f->isDeclaration() || f->hasAvailableExternallyLinkage())
|
if (isDeclaration(*f))
|
||||||
addPotentialUndefinedSymbol(f, mangler);
|
addPotentialUndefinedSymbol(f, mangler);
|
||||||
else
|
else
|
||||||
addDefinedFunctionSymbol(f, mangler);
|
addDefinedFunctionSymbol(f, mangler);
|
||||||
@ -654,7 +669,7 @@ bool LTOModule::ParseSymbols() {
|
|||||||
// add data
|
// add data
|
||||||
for (Module::global_iterator v = _module->global_begin(),
|
for (Module::global_iterator v = _module->global_begin(),
|
||||||
e = _module->global_end(); v != e; ++v) {
|
e = _module->global_end(); v != e; ++v) {
|
||||||
if (v->isDeclaration() || v->hasAvailableExternallyLinkage())
|
if (isDeclaration(*v))
|
||||||
addPotentialUndefinedSymbol(v, mangler);
|
addPotentialUndefinedSymbol(v, mangler);
|
||||||
else
|
else
|
||||||
addDefinedDataSymbol(v, mangler);
|
addDefinedDataSymbol(v, mangler);
|
||||||
@ -667,7 +682,7 @@ bool LTOModule::ParseSymbols() {
|
|||||||
// add aliases
|
// add aliases
|
||||||
for (Module::alias_iterator i = _module->alias_begin(),
|
for (Module::alias_iterator i = _module->alias_begin(),
|
||||||
e = _module->alias_end(); i != e; ++i) {
|
e = _module->alias_end(); i != e; ++i) {
|
||||||
if (i->isDeclaration())
|
if (isAliasToDeclaration(*i))
|
||||||
addPotentialUndefinedSymbol(i, mangler);
|
addPotentialUndefinedSymbol(i, mangler);
|
||||||
else
|
else
|
||||||
addDefinedDataSymbol(i, mangler);
|
addDefinedDataSymbol(i, mangler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user