mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
fix PR9015, a crash linking recursive metadata.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124099 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
96c0771c01
commit
51e62f0f73
@ -38,15 +38,16 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM,
|
||||
if (!MD->isFunctionLocal() && (Flags & RF_NoModuleLevelChanges))
|
||||
return VM[V] = const_cast<Value*>(V);
|
||||
|
||||
// Create a dummy node in case we have a metadata cycle.
|
||||
MDNode *Dummy = MDNode::getTemporary(V->getContext(), 0, 0);
|
||||
VM[V] = Dummy;
|
||||
|
||||
// Check all operands to see if any need to be remapped.
|
||||
for (unsigned i = 0, e = MD->getNumOperands(); i != e; ++i) {
|
||||
Value *OP = MD->getOperand(i);
|
||||
if (OP == 0 || MapValue(OP, VM, Flags) == OP) continue;
|
||||
|
||||
// Ok, at least one operand needs remapping. Create a dummy node in case
|
||||
// we have a metadata cycle.
|
||||
MDNode *Dummy = MDNode::getTemporary(V->getContext(), 0, 0);
|
||||
VM[V] = Dummy;
|
||||
// Ok, at least one operand needs remapping.
|
||||
SmallVector<Value*, 4> Elts;
|
||||
Elts.reserve(MD->getNumOperands());
|
||||
for (i = 0; i != e; ++i) {
|
||||
@ -55,12 +56,16 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM,
|
||||
}
|
||||
MDNode *NewMD = MDNode::get(V->getContext(), Elts.data(), Elts.size());
|
||||
Dummy->replaceAllUsesWith(NewMD);
|
||||
VM[V] = NewMD;
|
||||
MDNode::deleteTemporary(Dummy);
|
||||
return VM[V] = NewMD;
|
||||
return NewMD;
|
||||
}
|
||||
|
||||
VM[V] = const_cast<Value*>(V);
|
||||
MDNode::deleteTemporary(Dummy);
|
||||
|
||||
// No operands needed remapping. Use an identity mapping.
|
||||
return VM[V] = const_cast<Value*>(V);
|
||||
return const_cast<Value*>(V);
|
||||
}
|
||||
|
||||
// Okay, this either must be a constant (which may or may not be mappable) or
|
||||
|
@ -10,3 +10,4 @@ define void @foo() {
|
||||
%x = call i8 @llvm.something(metadata !21)
|
||||
ret void
|
||||
}
|
||||
|
||||
|
@ -10,3 +10,13 @@ define void @foo1() {
|
||||
%x = call i8 @llvm.something(metadata !22)
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
|
||||
; PR9015
|
||||
define void @test() {
|
||||
ret void, !abc !0
|
||||
}
|
||||
|
||||
!0 = metadata !{metadata !0, i32 42 }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user