diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 134a0a2019b..6db9ed55de2 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -92,6 +92,25 @@ Value *llvm::MapValue(const Value *V, std::map &VM) { return VMSlot = ConstantExpr::get(CE->getOpcode(), MV1, MV2); } + } else if (ConstantPacked *CP = dyn_cast(C)) { + for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i) { + Value *MV = MapValue(CP->getOperand(i), VM); + if (MV != CP->getOperand(i)) { + // This packed value must contain a reference to a global, make a new + // packed constant and return it. + // + std::vector Values; + Values.reserve(CP->getNumOperands()); + for (unsigned j = 0; j != i; ++j) + Values.push_back(CP->getOperand(j)); + Values.push_back(cast(MV)); + for (++i; i != e; ++i) + Values.push_back(cast(MapValue(CP->getOperand(i), VM))); + return VMSlot = ConstantPacked::get(Values); + } + } + return VMSlot = C; + } else { assert(0 && "Unknown type of constant!"); }