+ } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) {
+ if (CE->getOpcode() == Instruction::GetElementPtr) {
+ Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
+ std::vector<Constant*> Indices;
+ Indices.reserve(CE->getNumOperands()-1);
+ for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i)
+ Indices.push_back(cast<Constant>(RemapOperand(CE->getOperand(i),
+ LocalMap, GlobalMap)));
+
+ Result = ConstantExpr::getGetElementPtr(cast<Constant>(Ptr), Indices);
+ } else if (CE->getNumOperands() == 1) {
+ // Cast instruction
+ assert(CE->getOpcode() == Instruction::Cast);
+ Value *V = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
+ Result = ConstantExpr::getCast(cast<Constant>(V), CE->getType());
+ } else if (CE->getNumOperands() == 2) {
+ // Binary operator...
+ Value *V1 = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap);
+ Value *V2 = RemapOperand(CE->getOperand(1), LocalMap, GlobalMap);
+
+ Result = ConstantExpr::get(CE->getOpcode(), cast<Constant>(V1),
+ cast<Constant>(V2));
+ } else {
+ assert(0 && "Unknown constant expr type!");
+ }
+