summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-03-18 05:12:38 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-03-18 05:12:38 +0000
commitc78f65775abf72ae6786b416d60436ff7c989d0b (patch)
tree935840bb0d3f861760ed604d34cd6f5fb150a62e /llvm
parent4977655c940aa9478edbd7781e8348965e8c73bf (diff)
downloadbcm5719-llvm-c78f65775abf72ae6786b416d60436ff7c989d0b.tar.gz
bcm5719-llvm-c78f65775abf72ae6786b416d60436ff7c989d0b.zip
Simplify the computation of undefined symbols. Instead of walking
functions and initializers, just report the declarations present in the module. The motivation is to open the way for using the lazy module parsing, which should speed up clients that just want a symbol list (nm, ar). This is slightly less precise, but since both -strip-dead-prototypes and -globaldce are part of the standard pipeline, this shouldn't change the result for clang/dragonegg produced binaries. Any decl in an IL file was also put there because a FE expected it to be necessary, so this should not be a problem for "-O0 -emit-llvm". As a sanity check, I have bootstrapped clang on linux and built firefox on both linux and darwin. A clang bootstrap on darwin with LTO fails with or without this patch because, ironically, the linker doesn't like the combination of dead_strip and LTO when building libLTO.so :-) llvm-svn: 127870
Diffstat (limited to 'llvm')
-rw-r--r--llvm/tools/lto/LTOModule.cpp46
-rw-r--r--llvm/tools/lto/LTOModule.h2
2 files changed, 2 insertions, 46 deletions
diff --git a/llvm/tools/lto/LTOModule.cpp b/llvm/tools/lto/LTOModule.cpp
index 4e9e74f4984..4cfe9ad166e 100644
--- a/llvm/tools/lto/LTOModule.cpp
+++ b/llvm/tools/lto/LTOModule.cpp
@@ -178,16 +178,6 @@ void LTOModule::setTargetTriple(const char *triple) {
void LTOModule::addDefinedFunctionSymbol(Function *f, Mangler &mangler) {
// add to list of defined symbols
addDefinedSymbol(f, mangler, true);
-
- // add external symbols referenced by this function.
- for (Function::iterator b = f->begin(); b != f->end(); ++b) {
- for (BasicBlock::iterator i = b->begin(); i != b->end(); ++i) {
- for (unsigned count = 0, total = i->getNumOperands();
- count != total; ++count) {
- findExternalRefs(i->getOperand(count), mangler);
- }
- }
- }
}
// Get string that data pointer points to.
@@ -328,12 +318,6 @@ void LTOModule::addDefinedDataSymbol(GlobalValue *v, Mangler &mangler) {
}
}
}
-
- // add external symbols referenced by this data.
- for (unsigned count = 0, total = v->getNumOperands();
- count != total; ++count) {
- findExternalRefs(v->getOperand(count), mangler);
- }
}
@@ -343,10 +327,6 @@ void LTOModule::addDefinedSymbol(GlobalValue *def, Mangler &mangler,
if (def->getName().startswith("llvm."))
return;
- // ignore available_externally
- if (def->hasAvailableExternallyLinkage())
- return;
-
// string is owned by _defines
SmallString<64> Buffer;
mangler.getNameWithPrefix(Buffer, def, false);
@@ -471,28 +451,6 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue *decl,
}
-
-// Find external symbols referenced by VALUE. This is a recursive function.
-void LTOModule::findExternalRefs(Value *value, Mangler &mangler) {
- if (GlobalValue *gv = dyn_cast<GlobalValue>(value)) {
- if (!gv->hasExternalLinkage())
- addPotentialUndefinedSymbol(gv, mangler);
- // If this is a variable definition, do not recursively process
- // initializer. It might contain a reference to this variable
- // and cause an infinite loop. The initializer will be
- // processed in addDefinedDataSymbol().
- return;
- }
-
- // GlobalValue, even with InternalLinkage type, may have operands with
- // ExternalLinkage type. Do not ignore these operands.
- if (Constant *c = dyn_cast<Constant>(value)) {
- // Handle ConstantExpr, ConstantStruct, ConstantArry etc.
- for (unsigned i = 0, e = c->getNumOperands(); i != e; ++i)
- findExternalRefs(c->getOperand(i), mangler);
- }
-}
-
namespace {
class RecordStreamer : public MCStreamer {
public:
@@ -687,7 +645,7 @@ bool LTOModule::ParseSymbols() {
// add functions
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
- if (f->isDeclaration())
+ if (f->isDeclaration() || f->hasAvailableExternallyLinkage())
addPotentialUndefinedSymbol(f, mangler);
else
addDefinedFunctionSymbol(f, mangler);
@@ -696,7 +654,7 @@ bool LTOModule::ParseSymbols() {
// add data
for (Module::global_iterator v = _module->global_begin(),
e = _module->global_end(); v != e; ++v) {
- if (v->isDeclaration())
+ if (v->isDeclaration() || v->hasAvailableExternallyLinkage())
addPotentialUndefinedSymbol(v, mangler);
else
addDefinedDataSymbol(v, mangler);
diff --git a/llvm/tools/lto/LTOModule.h b/llvm/tools/lto/LTOModule.h
index 303151293b2..0b64a902f91 100644
--- a/llvm/tools/lto/LTOModule.h
+++ b/llvm/tools/lto/LTOModule.h
@@ -82,8 +82,6 @@ private:
bool isFunction);
void addPotentialUndefinedSymbol(llvm::GlobalValue* decl,
llvm::Mangler &mangler);
- void findExternalRefs(llvm::Value* value,
- llvm::Mangler& mangler);
void addDefinedFunctionSymbol(llvm::Function* f,
llvm::Mangler &mangler);
void addDefinedDataSymbol(llvm::GlobalValue* v,
OpenPOWER on IntegriCloud