From 1b3ef34b759434624bb0c194c2d368ba7617c3a9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 21 Jan 2010 21:05:54 +0000 Subject: [PATCH] tidy up git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94101 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/ValueMapper.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 37f65b0ba4a..50e36d83216 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -13,12 +13,10 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/ValueMapper.h" -#include "llvm/DerivedTypes.h" // For getNullValue(Type::Int32Ty) #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) { @@ -31,14 +29,13 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM) { // 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) && !dyn_cast(V)->isFunctionLocal())) + (isa(V) && !cast(V)->isFunctionLocal())) return VMSlot = const_cast(V); - if (isa(V)) { - const MDNode *MD = dyn_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) : NULL); + Elts.push_back(MD->getOperand(i) ? MapValue(MD->getOperand(i), VM) : 0); return VM[V] = MDNode::get(V->getContext(), Elts.data(), Elts.size()); } @@ -120,14 +117,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