summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/ValueMapper.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-29 00:31:02 +0000
committerChris Lattner <sabre@nondot.org>2009-10-29 00:31:02 +0000
commit1bb95911de8d0821aff16bf0cb1e1dfe43856bf1 (patch)
treedc4ef3f16903955347c92b4ee1e5988c3c7fd5b9 /lib/Transforms/Utils/ValueMapper.cpp
parent77488ccc6305760af485c884872368c7a490ab84 (diff)
teach ValueMapper about BlockAddress', making bugpoint a lot more useful.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r--lib/Transforms/Utils/ValueMapper.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp
index 7b1ae240da6..21126c94aef 100644
--- a/lib/Transforms/Utils/ValueMapper.cpp
+++ b/lib/Transforms/Utils/ValueMapper.cpp
@@ -13,11 +13,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/ValueMapper.h"
-#include "llvm/BasicBlock.h"
#include "llvm/DerivedTypes.h" // For getNullValue(Type::Int32Ty)
#include "llvm/Constants.h"
-#include "llvm/GlobalValue.h"
-#include "llvm/Instruction.h"
+#include "llvm/Function.h"
#include "llvm/Metadata.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ErrorHandling.h"
@@ -92,8 +90,8 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM) {
return VM[V] = CE->getWithOperands(Ops);
}
- if (ConstantVector *CP = dyn_cast<ConstantVector>(C)) {
- for (User::op_iterator b = CP->op_begin(), i = b, e = CP->op_end();
+ if (ConstantVector *CV = dyn_cast<ConstantVector>(C)) {
+ for (User::op_iterator b = CV->op_begin(), i = b, e = CV->op_end();
i != e; ++i) {
Value *MV = MapValue(*i, VM);
if (MV != *i) {
@@ -101,7 +99,7 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM) {
// vector constant and return it.
//
std::vector<Constant*> Values;
- Values.reserve(CP->getNumOperands());
+ Values.reserve(CV->getNumOperands());
for (User::op_iterator j = b; j != i; ++j)
Values.push_back(cast<Constant>(*j));
Values.push_back(cast<Constant>(MV));
@@ -111,7 +109,12 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM) {
}
}
return VM[V] = C;
-
+ }
+
+ if (BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
+ Function *F = cast<Function>(MapValue(BA->getFunction(), VM));
+ BasicBlock *BB = cast<BasicBlock>(MapValue(BA->getBasicBlock(), VM));
+ return VM[V] = BlockAddress::get(F, BB);
}
llvm_unreachable("Unknown type of constant!");