summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2008-05-27 22:07:08 +0000
committerNick Kledzik <kledzik@apple.com>2008-05-27 22:07:08 +0000
commitce956e0613334b60b4098317f7e4c46f392e3f44 (patch)
tree038c0b90d0e29b86ea07684b8745631ebf4417c4
parent29e0ad2ff11e3f05740f797b11c599ff98fd9e1d (diff)
downloadbcm5719-llvm-ce956e0613334b60b4098317f7e4c46f392e3f44.tar.gz
bcm5719-llvm-ce956e0613334b60b4098317f7e4c46f392e3f44.zip
fix infinite recursion if a global's initializer references the global
llvm-svn: 51617
-rw-r--r--llvm/tools/lto2/LTOModule.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/tools/lto2/LTOModule.cpp b/llvm/tools/lto2/LTOModule.cpp
index c4bee714c6c..eb0a094934f 100644
--- a/llvm/tools/lto2/LTOModule.cpp
+++ b/llvm/tools/lto2/LTOModule.cpp
@@ -161,7 +161,7 @@ void LTOModule::addDefinedDataSymbol(GlobalValue* v, Mangler &mangler)
addDefinedSymbol(v, mangler, false);
// add external symbols referenced by this data.
- for (unsigned count = 0, total = v->getNumOperands();\
+ for (unsigned count = 0, total = v->getNumOperands();
count != total; ++count) {
findExternalRefs(v->getOperand(count), mangler);
}
@@ -234,8 +234,13 @@ 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)) {
OpenPOWER on IntegriCloud