From 3fd58f91dd318518f7daa4ba64c0aaf31799d89b Mon Sep 17 00:00:00 2001 From: rdivacky Date: Sat, 23 Jan 2010 11:09:33 +0000 Subject: Update LLVM to r94309. --- lib/Transforms/Utils/ValueMapper.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'lib/Transforms/Utils/ValueMapper.cpp') diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 39331d7..a6e6701 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -13,12 +13,11 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/ValueMapper.h" -#include "llvm/DerivedTypes.h" // For getNullValue(Type::Int32Ty) +#include "llvm/Type.h" #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Metadata.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/Support/ErrorHandling.h" using namespace llvm; Value *llvm::MapValue(const Value *V, ValueMapTy &VM) { @@ -28,11 +27,19 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM) { // 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 metadata do not need to be seeded into the ValueMap if - // they are using the identity mapping. - if (isa(V) || isa(V) || isa(V)) + // Global values and non-function-local metadata do not need to be seeded into + // the ValueMap if they are using the identity mapping. + if (isa(V) || isa(V) || isa(V) || + (isa(V) && !cast(V)->isFunctionLocal())) return VMSlot = const_cast(V); + if (const MDNode *MD = dyn_cast(V)) { + SmallVector Elts; + for (unsigned i = 0; i != MD->getNumOperands(); i++) + Elts.push_back(MD->getOperand(i) ? MapValue(MD->getOperand(i), VM) : 0); + return VM[V] = MDNode::get(V->getContext(), Elts.data(), Elts.size()); + } + Constant *C = const_cast(dyn_cast(V)); if (C == 0) return 0; @@ -111,14 +118,10 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM) { return VM[V] = C; } - if (BlockAddress *BA = dyn_cast(C)) { - Function *F = cast(MapValue(BA->getFunction(), VM)); - BasicBlock *BB = cast_or_null(MapValue(BA->getBasicBlock(),VM)); - return VM[V] = BlockAddress::get(F, BB ? BB : BA->getBasicBlock()); - } - - llvm_unreachable("Unknown type of constant!"); - return 0; + BlockAddress *BA = cast(C); + Function *F = cast(MapValue(BA->getFunction(), VM)); + BasicBlock *BB = cast_or_null(MapValue(BA->getBasicBlock(),VM)); + return VM[V] = BlockAddress::get(F, BB ? BB : BA->getBasicBlock()); } /// RemapInstruction - Convert the instruction operands from referencing the @@ -131,3 +134,4 @@ void llvm::RemapInstruction(Instruction *I, ValueMapTy &ValueMap) { *op = V; } } + -- cgit v1.1