mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
Fix bug: Assembler/2003-05-15-AssemblerProblem.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6234 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a60f855dc6
commit
608f4b0287
@ -721,9 +721,8 @@ unsigned Constant::mutateReferences(Value *OldV, Value *NewV) {
|
||||
GlobalValue *OldGV = CPR->getValue();
|
||||
|
||||
assert(OldGV == OldV && "Cannot mutate old value if I'm not using it!");
|
||||
|
||||
OldGV->getParent()->mutateConstantPointerRef(OldGV, NewGV);
|
||||
Operands[0] = NewGV;
|
||||
OldGV->getParent()->mutateConstantPointerRef(OldGV, NewGV);
|
||||
return 1;
|
||||
} else {
|
||||
Constant *NewC = cast<Constant>(NewV);
|
||||
|
@ -250,6 +250,7 @@ void Module::destroyConstantPointerRef(ConstantPointerRef *CPR) {
|
||||
}
|
||||
|
||||
void Module::mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) {
|
||||
assert(OldGV != NewGV && "Cannot mutate to the same global!");
|
||||
GlobalValueRefMap::iterator I = GVRefMap->Map.find(OldGV);
|
||||
assert(I != GVRefMap->Map.end() &&
|
||||
"mutateConstantPointerRef; OldGV not in table!");
|
||||
@ -258,6 +259,16 @@ void Module::mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) {
|
||||
// Remove the old entry...
|
||||
GVRefMap->Map.erase(I);
|
||||
|
||||
// Check to see if a CPR already exists for NewGV
|
||||
I = GVRefMap->Map.lower_bound(NewGV);
|
||||
|
||||
if (I == GVRefMap->Map.end() || I->first != NewGV) {
|
||||
// Insert the new entry...
|
||||
GVRefMap->Map.insert(std::make_pair(NewGV, Ref));
|
||||
GVRefMap->Map.insert(I, std::make_pair(NewGV, Ref));
|
||||
} else {
|
||||
// Otherwise, an entry already exists for the current global value.
|
||||
// Completely replace the old CPR with the existing one...
|
||||
Ref->replaceAllUsesWith(I->second);
|
||||
delete Ref;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user