diff options
author | Devang Patel <dpatel@apple.com> | 2006-08-04 19:10:26 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-08-04 19:10:26 +0000 |
commit | 304d5f2edc954a3ef9904ea6d8f9421f40c9abe4 (patch) | |
tree | f20c66c17449331c1a146828c7a4ea03c908c608 | |
parent | a773bd54f32ceb55af08286fe00c6ec1b73e5b9a (diff) |
Collect references from globals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29530 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/lto/lto.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 3fbce69195..4a8e25cf98 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -85,15 +85,16 @@ getLTOLinkageType(GlobalValue *v) // Find exeternal symbols referenced by VALUE. This is a recursive function. static void findExternalRefs(Value *value, std::set<const char *> &references) { - - if (ConstantExpr *ce = dyn_cast<ConstantExpr>(value)) - for (unsigned i = 0, e = ce->getNumOperands(); i != e; ++i) - findExternalRefs(ce->getOperand(i), references); - else if (GlobalValue *gv = dyn_cast<GlobalValue>(value)) { + + if (GlobalValue *gv = dyn_cast<GlobalValue>(value)) { LTOLinkageTypes lt = getLTOLinkageType(gv); if (lt != LTOInternalLinkage && strncmp (gv->getName().c_str(), "llvm.", 5)) references.insert(addUnderscore(gv->getName().c_str())); } + else 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), references); } /// InputFilename is a LLVM bytecode file. Read it using bytecode reader. @@ -140,6 +141,11 @@ LinkTimeOptimizer::readLLVMObjectFile(const std::string &InputFilename, const char *name = addUnderscore(v->getName().c_str()); LLVMSymbol *newSymbol = new LLVMSymbol(lt,v); symbols[name] = newSymbol; + + for (unsigned count = 0, total = v->getNumOperands(); + count != total; ++count) + findExternalRefs(v->getOperand(count), references); + } } |