llvm.org GIT mirror llvm / 7a303d1
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 Chris Lattner 12 years ago
1 changed file(s) with 23 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
164164 Values[ValueID-1].second++;
165165 return;
166166 }
167
168 // Add the value.
169 Values.push_back(std::make_pair(V, 1U));
170 ValueID = Values.size();
171
167
168 // Enumerate the type of this value.
169 EnumerateType(V->getType());
170
172171 if (const Constant *C = dyn_cast(V)) {
173172 if (isa(C)) {
174173 // Initializers for globals are handled explicitly elsewhere.
176175 // Do not enumerate the initializers for an array of simple characters.
177176 // The initializers just polute the value table, and we emit the strings
178177 // specially.
179 } else {
180 // This makes sure that if a constant has uses (for example an array of
181 // const ints), that they are inserted also.
178 } else if (C->getNumOperands()) {
179 // If a constant has operands, enumerate them. This makes sure that if a
180 // constant has uses (for example an array of const ints), that they are
181 // inserted also.
182
183 // We prefer to enumerate them with values before we enumerate the user
184 // itself. This makes it more likely that we can avoid forward references
185 // in the reader. We know that there can be no cycles in the constants
186 // graph that don't go through a global variable.
182187 for (User::const_op_iterator I = C->op_begin(), E = C->op_end();
183188 I != E; ++I)
184189 EnumerateValue(*I);
190
191 // Finally, add the value. Doing this could make the ValueID reference be
192 // dangling, don't reuse it.
193 Values.push_back(std::make_pair(V, 1U));
194 ValueMap[V] = Values.size();
195 return;
185196 }
186197 }
187
188 EnumerateType(V->getType());
198
199 // Add the value.
200 Values.push_back(std::make_pair(V, 1U));
201 ValueID = Values.size();
189202 }
190203
191204