[llvm-commits] [llvm] r85458 - /llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp

Chris Lattner sabre at nondot.org
Wed Oct 28 17:31:03 PDT 2009


Author: lattner
Date: Wed Oct 28 19:31:02 2009
New Revision: 85458

URL: http://llvm.org/viewvc/llvm-project?rev=85458&view=rev
Log:
teach ValueMapper about BlockAddress', making bugpoint a lot more useful.

Modified:
    llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp

Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=85458&r1=85457&r2=85458&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Wed Oct 28 19:31:02 2009
@@ -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 @@
     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 @@
         // 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 @@
       }
     }
     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!");





More information about the llvm-commits mailing list