mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
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
This commit is contained in:
1 parent
1b9e1672fb
commit
9178a65263
1 file changed
+7
-2
@@ -161,7 +161,7 @@ void LTOModule::addDefinedDataSymbol(GlobalValue* v, Mangler &mangler)
|
|||||||
addDefinedSymbol(v, mangler, false);
|
addDefinedSymbol(v, mangler, false);
|
||||||
|
|
||||||
// add external symbols referenced by this data.
|
// add external symbols referenced by this data.
|
||||||
for (unsigned count = 0, total = v->getNumOperands();\
|
for (unsigned count = 0, total = v->getNumOperands();
|
||||||
count != total; ++count) {
|
count != total; ++count) {
|
||||||
findExternalRefs(v->getOperand(count), mangler);
|
findExternalRefs(v->getOperand(count), mangler);
|
||||||
}
|
}
|
||||||
@@ -234,8 +234,13 @@ void LTOModule::findExternalRefs(Value* value, Mangler &mangler) {
|
|||||||
if (GlobalValue* gv = dyn_cast<GlobalValue>(value)) {
|
if (GlobalValue* gv = dyn_cast<GlobalValue>(value)) {
|
||||||
if ( !gv->hasExternalLinkage() )
|
if ( !gv->hasExternalLinkage() )
|
||||||
addPotentialUndefinedSymbol(gv, mangler);
|
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
|
// GlobalValue, even with InternalLinkage type, may have operands with
|
||||||
// ExternalLinkage type. Do not ignore these operands.
|
// ExternalLinkage type. Do not ignore these operands.
|
||||||
if (Constant* c = dyn_cast<Constant>(value)) {
|
if (Constant* c = dyn_cast<Constant>(value)) {
|
||||||
|
|||||||
Reference in new issue
Block a user