mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
enumerate the operands of a constant before we enumerate the constant itself
This avoids fwd references in the reader. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36822 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cb3d91b05b
commit
7a303d1591
@ -165,11 +165,10 @@ void ValueEnumerator::EnumerateValue(const Value *V) {
|
|||||||
Values[ValueID-1].second++;
|
Values[ValueID-1].second++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the value.
|
|
||||||
Values.push_back(std::make_pair(V, 1U));
|
|
||||||
ValueID = Values.size();
|
|
||||||
|
|
||||||
|
// Enumerate the type of this value.
|
||||||
|
EnumerateType(V->getType());
|
||||||
|
|
||||||
if (const Constant *C = dyn_cast<Constant>(V)) {
|
if (const Constant *C = dyn_cast<Constant>(V)) {
|
||||||
if (isa<GlobalValue>(C)) {
|
if (isa<GlobalValue>(C)) {
|
||||||
// Initializers for globals are handled explicitly elsewhere.
|
// Initializers for globals are handled explicitly elsewhere.
|
||||||
@ -177,16 +176,30 @@ void ValueEnumerator::EnumerateValue(const Value *V) {
|
|||||||
// Do not enumerate the initializers for an array of simple characters.
|
// Do not enumerate the initializers for an array of simple characters.
|
||||||
// The initializers just polute the value table, and we emit the strings
|
// The initializers just polute the value table, and we emit the strings
|
||||||
// specially.
|
// specially.
|
||||||
} else {
|
} else if (C->getNumOperands()) {
|
||||||
// This makes sure that if a constant has uses (for example an array of
|
// If a constant has operands, enumerate them. This makes sure that if a
|
||||||
// const ints), that they are inserted also.
|
// constant has uses (for example an array of const ints), that they are
|
||||||
|
// inserted also.
|
||||||
|
|
||||||
|
// We prefer to enumerate them with values before we enumerate the user
|
||||||
|
// itself. This makes it more likely that we can avoid forward references
|
||||||
|
// in the reader. We know that there can be no cycles in the constants
|
||||||
|
// graph that don't go through a global variable.
|
||||||
for (User::const_op_iterator I = C->op_begin(), E = C->op_end();
|
for (User::const_op_iterator I = C->op_begin(), E = C->op_end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
EnumerateValue(*I);
|
EnumerateValue(*I);
|
||||||
|
|
||||||
|
// Finally, add the value. Doing this could make the ValueID reference be
|
||||||
|
// dangling, don't reuse it.
|
||||||
|
Values.push_back(std::make_pair(V, 1U));
|
||||||
|
ValueMap[V] = Values.size();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumerateType(V->getType());
|
// Add the value.
|
||||||
|
Values.push_back(std::make_pair(V, 1U));
|
||||||
|
ValueID = Values.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user