diff options
author | Nick Kledzik <kledzik@apple.com> | 2008-05-27 22:07:08 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2008-05-27 22:07:08 +0000 |
commit | 9178a65263bb1f00bb52a53e4e371f62db27d3bb (patch) | |
tree | 8d42b81614b59e66f0af7ae7d6dc7969b8b85ee6 | |
parent | 1b9e1672fb68c399fc277a33f959be018c6796fd (diff) | |
download | external_llvm-9178a65263bb1f00bb52a53e4e371f62db27d3bb.zip external_llvm-9178a65263bb1f00bb52a53e4e371f62db27d3bb.tar.gz external_llvm-9178a65263bb1f00bb52a53e4e371f62db27d3bb.tar.bz2 |
fix infinite recursion if a global's initializer references the global
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51617 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/lto2/LTOModule.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/lto2/LTOModule.cpp b/tools/lto2/LTOModule.cpp index c4bee71..eb0a094 100644 --- a/tools/lto2/LTOModule.cpp +++ b/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)) { |