llvm.org GIT mirror llvm / 652f032
Fix bug: Linker/2003-08-28-TypeResolvesGlobal.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8202 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 12 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
230230 GlobalValue *ExistGV = dyn_cast(TI->second);
231231 GlobalValue *NewGV = dyn_cast(V.second);
232232
233 if (ExistGV && NewGV && ExistGV->isExternal() && NewGV->isExternal()) {
233 if (ExistGV && NewGV) {
234 assert((ExistGV->isExternal() || NewGV->isExternal()) &&
235 "Two planes folded together with overlapping value names!");
236
237 // Make sure that ExistGV is the one we want to keep!
238 if (!NewGV->isExternal() || !NewGV->use_empty()) {
239 std::swap(NewGV, ExistGV);
240 }
241
234242 // Ok we have two external global values. Make all uses of the new
235243 // one use the old one...
236244 //
237 assert(ExistGV->use_empty() && "No uses allowed on untyped value!");
245 assert(NewGV->use_empty() && "No uses allowed on untyped value!");
246
247 // We cannot replaceAllUsesWith, because they have different types!
238248 //NewGV->replaceAllUsesWith(ExistGV);
239249
240250 // Now we just convert it to an unnamed method... which won't get
260270 else
261271 M->getGlobalList().remove(cast(NewGV));
262272 delete NewGV;
263
264 } else {
265 assert(0 && "Two planes folded together with overlapping "
266 "value names!");
267273 }
268274 } else {
269275 insertEntry(V.first, NewType, V.second);