mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
Revert 106592 for now. It causes clang-selfhost build failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106598 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
caf71ab473
commit
170f06ebe2
@ -21,44 +21,23 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM) {
|
Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM) {
|
||||||
ValueToValueMapTy::iterator VMI = VM.find(V);
|
Value *&VMSlot = VM[V];
|
||||||
if (VMI != VM.end())
|
if (VMSlot) return VMSlot; // Does it exist in the map yet?
|
||||||
return VMI->second; // Does it exist in the map yet?
|
|
||||||
|
|
||||||
// Global values, metadata strings and inline asm do not need to be seeded into
|
// NOTE: VMSlot can be invalidated by any reference to VM, which can grow the
|
||||||
|
// DenseMap. This includes any recursive calls to MapValue.
|
||||||
|
|
||||||
|
// Global values and non-function-local metadata do not need to be seeded into
|
||||||
// the ValueMap if they are using the identity mapping.
|
// the ValueMap if they are using the identity mapping.
|
||||||
if (isa<GlobalValue>(V) || isa<InlineAsm>(V) || isa<MDString>(V)) {
|
if (isa<GlobalValue>(V) || isa<InlineAsm>(V) || isa<MDString>(V) ||
|
||||||
VM.insert(std::make_pair(V, const_cast<Value*>(V)));
|
(isa<MDNode>(V) && !cast<MDNode>(V)->isFunctionLocal()))
|
||||||
return const_cast<Value*>(V);
|
return VMSlot = const_cast<Value*>(V);
|
||||||
}
|
|
||||||
|
|
||||||
if (const MDNode *MD = dyn_cast<MDNode>(V)) {
|
if (const MDNode *MD = dyn_cast<MDNode>(V)) {
|
||||||
// Insert a place holder in map to handle mdnode cycles.
|
|
||||||
Value *TmpV = MDString::get(V->getContext(),
|
|
||||||
std::string("llvm.md.clone.tmp." + VM.size()));
|
|
||||||
VM.insert(std::make_pair(V, MDNode::get(V->getContext(), &TmpV, 1)));
|
|
||||||
|
|
||||||
bool ReuseMD = true;
|
|
||||||
SmallVector<Value*, 4> Elts;
|
SmallVector<Value*, 4> Elts;
|
||||||
// If metadata element is mapped to a new value then seed metadata
|
for (unsigned i = 0, e = MD->getNumOperands(); i != e; ++i)
|
||||||
// in the map.
|
Elts.push_back(MD->getOperand(i) ? MapValue(MD->getOperand(i), VM) : 0);
|
||||||
for (unsigned i = 0, e = MD->getNumOperands(); i != e; ++i) {
|
return VM[V] = MDNode::get(V->getContext(), Elts.data(), Elts.size());
|
||||||
if (!MD->getOperand(i))
|
|
||||||
Elts.push_back(0);
|
|
||||||
else {
|
|
||||||
Value *MappedOp = MapValue(MD->getOperand(i), VM);
|
|
||||||
if (MappedOp != MD->getOperand(i))
|
|
||||||
ReuseMD = false;
|
|
||||||
Elts.push_back(MappedOp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ReuseMD) {
|
|
||||||
VM.insert(std::make_pair(V, const_cast<Value*>(V)));
|
|
||||||
return const_cast<Value*>(V);
|
|
||||||
}
|
|
||||||
MDNode *NewMD = MDNode::get(V->getContext(), Elts.data(), Elts.size());
|
|
||||||
VM.insert(std::make_pair(V, NewMD));
|
|
||||||
return NewMD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *C = const_cast<Constant*>(dyn_cast<Constant>(V));
|
Constant *C = const_cast<Constant*>(dyn_cast<Constant>(V));
|
||||||
@ -67,7 +46,7 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM) {
|
|||||||
if (isa<ConstantInt>(C) || isa<ConstantFP>(C) ||
|
if (isa<ConstantInt>(C) || isa<ConstantFP>(C) ||
|
||||||
isa<ConstantPointerNull>(C) || isa<ConstantAggregateZero>(C) ||
|
isa<ConstantPointerNull>(C) || isa<ConstantAggregateZero>(C) ||
|
||||||
isa<UndefValue>(C) || isa<MDString>(C))
|
isa<UndefValue>(C) || isa<MDString>(C))
|
||||||
return VM[V] = C; // Primitive constants map directly
|
return VMSlot = C; // Primitive constants map directly
|
||||||
|
|
||||||
if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) {
|
if (ConstantArray *CA = dyn_cast<ConstantArray>(C)) {
|
||||||
for (User::op_iterator b = CA->op_begin(), i = b, e = CA->op_end();
|
for (User::op_iterator b = CA->op_begin(), i = b, e = CA->op_end();
|
||||||
|
Loading…
Reference in New Issue
Block a user