Chris Lattner | e4dbb1a | 2002-11-20 20:47:41 +0000 | [diff] [blame] | 1 | //===- ValueMapper.cpp - Interface shared by lib/Transforms/Utils ---------===// |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 482202a | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 482202a | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | e4dbb1a | 2002-11-20 20:47:41 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file defines the MapValue function, which is shared by various parts of |
| 11 | // the lib/Transforms/Utils library. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Dan Gohman | a209503 | 2010-08-24 18:50:07 +0000 | [diff] [blame] | 15 | #include "llvm/Transforms/Utils/ValueMapper.h" |
David Blaikie | 348de69 | 2015-04-23 21:36:23 +0000 | [diff] [blame] | 16 | #include "llvm/IR/CallSite.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 17 | #include "llvm/IR/Constants.h" |
| 18 | #include "llvm/IR/Function.h" |
| 19 | #include "llvm/IR/InlineAsm.h" |
| 20 | #include "llvm/IR/Instructions.h" |
| 21 | #include "llvm/IR/Metadata.h" |
David Blaikie | 8820884 | 2015-08-21 20:16:51 +0000 | [diff] [blame] | 22 | #include "llvm/IR/Operator.h" |
Chris Lattner | df3c342 | 2004-01-09 06:12:26 +0000 | [diff] [blame] | 23 | using namespace llvm; |
Chris Lattner | e4dbb1a | 2002-11-20 20:47:41 +0000 | [diff] [blame] | 24 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 25 | // Out of line method to get vtable etc for class. |
Craig Topper | 2a6a08b | 2012-09-26 06:36:36 +0000 | [diff] [blame] | 26 | void ValueMapTypeRemapper::anchor() {} |
James Molloy | f6f121e | 2013-05-28 15:17:05 +0000 | [diff] [blame] | 27 | void ValueMaterializer::anchor() {} |
Rafael Espindola | 19b5238 | 2015-11-27 20:28:19 +0000 | [diff] [blame] | 28 | void ValueMaterializer::materializeInitFor(GlobalValue *New, GlobalValue *Old) { |
| 29 | } |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 30 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 31 | namespace { |
| 32 | |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 33 | /// A GlobalValue whose initializer needs to be materialized. |
| 34 | struct DelayedGlobalValueInit { |
| 35 | GlobalValue *Old; |
| 36 | GlobalValue *New; |
| 37 | DelayedGlobalValueInit(const GlobalValue *Old, GlobalValue *New) |
| 38 | : Old(const_cast<GlobalValue *>(Old)), New(New) {} |
| 39 | }; |
| 40 | |
| 41 | /// A basic block used in a BlockAddress whose function body is not yet |
| 42 | /// materialized. |
| 43 | struct DelayedBasicBlock { |
| 44 | BasicBlock *OldBB; |
| 45 | std::unique_ptr<BasicBlock> TempBB; |
Duncan P. N. Exon Smith | a997856 | 2016-04-03 20:42:21 +0000 | [diff] [blame] | 46 | |
| 47 | // Explicit move for MSVC. |
| 48 | DelayedBasicBlock(DelayedBasicBlock &&X) |
| 49 | : OldBB(std::move(X.OldBB)), TempBB(std::move(X.TempBB)) {} |
| 50 | DelayedBasicBlock &operator=(DelayedBasicBlock &&X) { |
| 51 | OldBB = std::move(X.OldBB); |
| 52 | TempBB = std::move(X.TempBB); |
| 53 | return *this; |
| 54 | } |
| 55 | |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 56 | DelayedBasicBlock(const BlockAddress &Old) |
| 57 | : OldBB(Old.getBasicBlock()), |
| 58 | TempBB(BasicBlock::Create(Old.getContext())) {} |
| 59 | }; |
| 60 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 61 | class Mapper { |
| 62 | ValueToValueMapTy &VM; |
| 63 | RemapFlags Flags; |
| 64 | ValueMapTypeRemapper *TypeMapper; |
| 65 | ValueMaterializer *Materializer; |
| 66 | |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 67 | SmallVector<DelayedGlobalValueInit, 8> DelayedInits; |
| 68 | SmallVector<DelayedBasicBlock, 1> DelayedBBs; |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 69 | SmallVector<MDNode *, 8> DistinctWorklist; |
| 70 | |
| 71 | public: |
| 72 | Mapper(ValueToValueMapTy &VM, RemapFlags Flags, |
| 73 | ValueMapTypeRemapper *TypeMapper, ValueMaterializer *Materializer) |
| 74 | : VM(VM), Flags(Flags), TypeMapper(TypeMapper), |
| 75 | Materializer(Materializer) {} |
| 76 | |
| 77 | ~Mapper(); |
| 78 | |
| 79 | Value *mapValue(const Value *V); |
| 80 | |
| 81 | /// Map metadata. |
| 82 | /// |
| 83 | /// Find the mapping for MD. Guarantees that the return will be resolved |
| 84 | /// (not an MDNode, or MDNode::isResolved() returns true). |
| 85 | Metadata *mapMetadata(const Metadata *MD); |
| 86 | |
| 87 | private: |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 88 | Value *mapBlockAddress(const BlockAddress &BA); |
| 89 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 90 | /// Map metadata helper. |
| 91 | /// |
| 92 | /// Co-recursively finds the mapping for MD. If this returns an MDNode, it's |
| 93 | /// possible that MDNode::isResolved() will return false. |
| 94 | Metadata *mapMetadataImpl(const Metadata *MD); |
| 95 | Metadata *mapMetadataOp(Metadata *Op); |
| 96 | |
Duncan P. N. Exon Smith | ae8bd4b | 2016-04-03 19:31:01 +0000 | [diff] [blame] | 97 | /// Map metadata that doesn't require visiting operands. |
| 98 | Optional<Metadata *> mapSimpleMetadata(const Metadata *MD); |
| 99 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 100 | /// Remap the operands of an MDNode. |
| 101 | /// |
| 102 | /// If \c Node is temporary, uniquing cycles are ignored. If \c Node is |
| 103 | /// distinct, uniquing cycles are resolved as they're found. |
| 104 | /// |
| 105 | /// \pre \c Node.isDistinct() or \c Node.isTemporary(). |
| 106 | bool remapOperands(MDNode &Node); |
| 107 | |
| 108 | /// Map a distinct MDNode. |
| 109 | /// |
| 110 | /// Whether distinct nodes change is independent of their operands. If \a |
| 111 | /// RF_MoveDistinctMDs, then they are reused, and their operands remapped in |
| 112 | /// place; effectively, they're moved from one graph to another. Otherwise, |
| 113 | /// they're cloned/duplicated, and the new copy's operands are remapped. |
| 114 | Metadata *mapDistinctNode(const MDNode *Node); |
| 115 | |
| 116 | /// Map a uniqued MDNode. |
| 117 | /// |
| 118 | /// Uniqued nodes may not need to be recreated (they may map to themselves). |
| 119 | Metadata *mapUniquedNode(const MDNode *Node); |
| 120 | |
| 121 | Metadata *mapToMetadata(const Metadata *Key, Metadata *Val); |
| 122 | Metadata *mapToSelf(const Metadata *MD); |
| 123 | }; |
| 124 | |
| 125 | } // end namespace |
| 126 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 127 | Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags, |
James Molloy | f6f121e | 2013-05-28 15:17:05 +0000 | [diff] [blame] | 128 | ValueMapTypeRemapper *TypeMapper, |
| 129 | ValueMaterializer *Materializer) { |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 130 | return Mapper(VM, Flags, TypeMapper, Materializer).mapValue(V); |
| 131 | } |
| 132 | |
| 133 | Value *Mapper::mapValue(const Value *V) { |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 134 | ValueToValueMapTy::iterator I = VM.find(V); |
Chris Lattner | 1bfc7ab | 2007-02-03 00:08:31 +0000 | [diff] [blame] | 135 | |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 136 | // If the value already exists in the map, use it. |
| 137 | if (I != VM.end() && I->second) return I->second; |
| 138 | |
James Molloy | f6f121e | 2013-05-28 15:17:05 +0000 | [diff] [blame] | 139 | // If we have a materializer and it can materialize a value, use that. |
| 140 | if (Materializer) { |
Rafael Espindola | 19b5238 | 2015-11-27 20:28:19 +0000 | [diff] [blame] | 141 | if (Value *NewV = |
| 142 | Materializer->materializeDeclFor(const_cast<Value *>(V))) { |
| 143 | VM[V] = NewV; |
Rafael Espindola | baa3bf8 | 2015-12-01 15:19:48 +0000 | [diff] [blame] | 144 | if (auto *NewGV = dyn_cast<GlobalValue>(NewV)) |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 145 | DelayedInits.push_back( |
| 146 | DelayedGlobalValueInit(cast<GlobalValue>(V), NewGV)); |
Rafael Espindola | 19b5238 | 2015-11-27 20:28:19 +0000 | [diff] [blame] | 147 | return NewV; |
| 148 | } |
James Molloy | f6f121e | 2013-05-28 15:17:05 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 151 | // Global values do not need to be seeded into the VM if they |
| 152 | // are using the identity mapping. |
Teresa Johnson | 83d03dd | 2015-11-15 14:50:14 +0000 | [diff] [blame] | 153 | if (isa<GlobalValue>(V)) { |
| 154 | if (Flags & RF_NullMapMissingGlobalValues) { |
| 155 | assert(!(Flags & RF_IgnoreMissingEntries) && |
| 156 | "Illegal to specify both RF_NullMapMissingGlobalValues and " |
| 157 | "RF_IgnoreMissingEntries"); |
| 158 | return nullptr; |
| 159 | } |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 160 | return VM[V] = const_cast<Value*>(V); |
Teresa Johnson | 83d03dd | 2015-11-15 14:50:14 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Chris Lattner | 8b4cf5e | 2011-07-15 23:18:40 +0000 | [diff] [blame] | 163 | if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) { |
| 164 | // Inline asm may need *type* remapping. |
| 165 | FunctionType *NewTy = IA->getFunctionType(); |
| 166 | if (TypeMapper) { |
| 167 | NewTy = cast<FunctionType>(TypeMapper->remapType(NewTy)); |
| 168 | |
| 169 | if (NewTy != IA->getFunctionType()) |
| 170 | V = InlineAsm::get(NewTy, IA->getAsmString(), IA->getConstraintString(), |
| 171 | IA->hasSideEffects(), IA->isAlignStack()); |
| 172 | } |
| 173 | |
| 174 | return VM[V] = const_cast<Value*>(V); |
| 175 | } |
Chris Lattner | 6aa34b0 | 2003-10-06 15:23:43 +0000 | [diff] [blame] | 176 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 177 | if (const auto *MDV = dyn_cast<MetadataAsValue>(V)) { |
| 178 | const Metadata *MD = MDV->getMetadata(); |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 179 | // If this is a module-level metadata and we know that nothing at the module |
| 180 | // level is changing, then use an identity mapping. |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 181 | if (!isa<LocalAsMetadata>(MD) && (Flags & RF_NoModuleLevelChanges)) |
| 182 | return VM[V] = const_cast<Value *>(V); |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 183 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 184 | auto *MappedMD = mapMetadata(MD); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 185 | if (MD == MappedMD || (!MappedMD && (Flags & RF_IgnoreMissingEntries))) |
| 186 | return VM[V] = const_cast<Value *>(V); |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 187 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 188 | return VM[V] = MetadataAsValue::get(V->getContext(), MappedMD); |
Victor Hernandez | 5fa88d4 | 2010-01-20 05:49:59 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 191 | // Okay, this either must be a constant (which may or may not be mappable) or |
| 192 | // is something that is not in the mapping table. |
Chris Lattner | cf5a47d | 2009-10-29 00:28:30 +0000 | [diff] [blame] | 193 | Constant *C = const_cast<Constant*>(dyn_cast<Constant>(V)); |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 194 | if (!C) |
| 195 | return nullptr; |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 196 | |
| 197 | if (BlockAddress *BA = dyn_cast<BlockAddress>(C)) |
| 198 | return mapBlockAddress(*BA); |
| 199 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 200 | // Otherwise, we have some other constant to remap. Start by checking to see |
| 201 | // if all operands have an identity remapping. |
| 202 | unsigned OpNo = 0, NumOperands = C->getNumOperands(); |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 203 | Value *Mapped = nullptr; |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 204 | for (; OpNo != NumOperands; ++OpNo) { |
| 205 | Value *Op = C->getOperand(OpNo); |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 206 | Mapped = mapValue(Op); |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 207 | if (Mapped != C) break; |
Chris Lattner | cf5a47d | 2009-10-29 00:28:30 +0000 | [diff] [blame] | 208 | } |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 209 | |
| 210 | // See if the type mapper wants to remap the type as well. |
| 211 | Type *NewTy = C->getType(); |
| 212 | if (TypeMapper) |
| 213 | NewTy = TypeMapper->remapType(NewTy); |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 214 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 215 | // If the result type and all operands match up, then just insert an identity |
| 216 | // mapping. |
| 217 | if (OpNo == NumOperands && NewTy == C->getType()) |
| 218 | return VM[V] = C; |
| 219 | |
| 220 | // Okay, we need to create a new constant. We've already processed some or |
| 221 | // all of the operands, set them all up now. |
| 222 | SmallVector<Constant*, 8> Ops; |
| 223 | Ops.reserve(NumOperands); |
| 224 | for (unsigned j = 0; j != OpNo; ++j) |
| 225 | Ops.push_back(cast<Constant>(C->getOperand(j))); |
| 226 | |
| 227 | // If one of the operands mismatch, push it and the other mapped operands. |
| 228 | if (OpNo != NumOperands) { |
| 229 | Ops.push_back(cast<Constant>(Mapped)); |
| 230 | |
| 231 | // Map the rest of the operands that aren't processed yet. |
| 232 | for (++OpNo; OpNo != NumOperands; ++OpNo) |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 233 | Ops.push_back(cast<Constant>(mapValue(C->getOperand(OpNo)))); |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 234 | } |
David Blaikie | 8820884 | 2015-08-21 20:16:51 +0000 | [diff] [blame] | 235 | Type *NewSrcTy = nullptr; |
| 236 | if (TypeMapper) |
| 237 | if (auto *GEPO = dyn_cast<GEPOperator>(C)) |
| 238 | NewSrcTy = TypeMapper->remapType(GEPO->getSourceElementType()); |
| 239 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 240 | if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) |
David Blaikie | 8820884 | 2015-08-21 20:16:51 +0000 | [diff] [blame] | 241 | return VM[V] = CE->getWithOperands(Ops, NewTy, false, NewSrcTy); |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 242 | if (isa<ConstantArray>(C)) |
| 243 | return VM[V] = ConstantArray::get(cast<ArrayType>(NewTy), Ops); |
| 244 | if (isa<ConstantStruct>(C)) |
| 245 | return VM[V] = ConstantStruct::get(cast<StructType>(NewTy), Ops); |
| 246 | if (isa<ConstantVector>(C)) |
| 247 | return VM[V] = ConstantVector::get(Ops); |
| 248 | // If this is a no-operand constant, it must be because the type was remapped. |
| 249 | if (isa<UndefValue>(C)) |
| 250 | return VM[V] = UndefValue::get(NewTy); |
| 251 | if (isa<ConstantAggregateZero>(C)) |
| 252 | return VM[V] = ConstantAggregateZero::get(NewTy); |
| 253 | assert(isa<ConstantPointerNull>(C)); |
| 254 | return VM[V] = ConstantPointerNull::get(cast<PointerType>(NewTy)); |
Chris Lattner | e4dbb1a | 2002-11-20 20:47:41 +0000 | [diff] [blame] | 255 | } |
Brian Gaeke | 6182acf | 2004-05-19 09:08:12 +0000 | [diff] [blame] | 256 | |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 257 | Value *Mapper::mapBlockAddress(const BlockAddress &BA) { |
| 258 | Function *F = cast<Function>(mapValue(BA.getFunction())); |
| 259 | |
| 260 | // F may not have materialized its initializer. In that case, create a |
| 261 | // dummy basic block for now, and replace it once we've materialized all |
| 262 | // the initializers. |
| 263 | BasicBlock *BB; |
| 264 | if (F->isDeclaration()) { |
| 265 | BB = cast_or_null<BasicBlock>(mapValue(BA.getBasicBlock())); |
| 266 | } else { |
| 267 | DelayedBBs.push_back(DelayedBasicBlock(BA)); |
| 268 | BB = DelayedBBs.back().TempBB.get(); |
| 269 | } |
| 270 | |
| 271 | return VM[&BA] = BlockAddress::get(F, BB ? BB : BA.getBasicBlock()); |
| 272 | } |
| 273 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 274 | Metadata *Mapper::mapToMetadata(const Metadata *Key, Metadata *Val) { |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 275 | VM.MD()[Key].reset(Val); |
| 276 | return Val; |
| 277 | } |
| 278 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 279 | Metadata *Mapper::mapToSelf(const Metadata *MD) { |
| 280 | return mapToMetadata(MD, const_cast<Metadata *>(MD)); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 283 | Metadata *Mapper::mapMetadataOp(Metadata *Op) { |
Duncan P. N. Exon Smith | 077affd | 2015-01-14 01:01:19 +0000 | [diff] [blame] | 284 | if (!Op) |
| 285 | return nullptr; |
Teresa Johnson | 0e7c82c | 2015-12-18 17:51:37 +0000 | [diff] [blame] | 286 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 287 | if (Metadata *MappedOp = mapMetadataImpl(Op)) |
Duncan P. N. Exon Smith | 077affd | 2015-01-14 01:01:19 +0000 | [diff] [blame] | 288 | return MappedOp; |
| 289 | // Use identity map if MappedOp is null and we can ignore missing entries. |
| 290 | if (Flags & RF_IgnoreMissingEntries) |
| 291 | return Op; |
| 292 | |
Duncan P. N. Exon Smith | 077affd | 2015-01-14 01:01:19 +0000 | [diff] [blame] | 293 | return nullptr; |
| 294 | } |
| 295 | |
Duncan P. N. Exon Smith | c9fdbdb | 2015-08-07 00:39:26 +0000 | [diff] [blame] | 296 | /// Resolve uniquing cycles involving the given metadata. |
Teresa Johnson | b703c77 | 2016-03-29 18:24:19 +0000 | [diff] [blame] | 297 | static void resolveCycles(Metadata *MD) { |
| 298 | if (auto *N = dyn_cast_or_null<MDNode>(MD)) |
| 299 | if (!N->isResolved()) |
| 300 | N->resolveCycles(); |
Duncan P. N. Exon Smith | c9fdbdb | 2015-08-07 00:39:26 +0000 | [diff] [blame] | 301 | } |
| 302 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 303 | bool Mapper::remapOperands(MDNode &Node) { |
Duncan P. N. Exon Smith | 2705097 | 2015-08-05 23:22:34 +0000 | [diff] [blame] | 304 | assert(!Node.isUniqued() && "Expected temporary or distinct node"); |
Duncan P. N. Exon Smith | 8c9dcac | 2015-08-07 00:44:55 +0000 | [diff] [blame] | 305 | const bool IsDistinct = Node.isDistinct(); |
Duncan P. N. Exon Smith | 6dc22bf | 2015-01-19 22:44:32 +0000 | [diff] [blame] | 306 | |
Duncan P. N. Exon Smith | 6dc22bf | 2015-01-19 22:44:32 +0000 | [diff] [blame] | 307 | bool AnyChanged = false; |
Duncan P. N. Exon Smith | 2705097 | 2015-08-05 23:22:34 +0000 | [diff] [blame] | 308 | for (unsigned I = 0, E = Node.getNumOperands(); I != E; ++I) { |
| 309 | Metadata *Old = Node.getOperand(I); |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 310 | Metadata *New = mapMetadataOp(Old); |
Duncan P. N. Exon Smith | 6dc22bf | 2015-01-19 22:44:32 +0000 | [diff] [blame] | 311 | if (Old != New) { |
| 312 | AnyChanged = true; |
Duncan P. N. Exon Smith | 2705097 | 2015-08-05 23:22:34 +0000 | [diff] [blame] | 313 | Node.replaceOperandWith(I, New); |
Duncan P. N. Exon Smith | 8c9dcac | 2015-08-07 00:44:55 +0000 | [diff] [blame] | 314 | |
| 315 | // Resolve uniquing cycles underneath distinct nodes on the fly so they |
| 316 | // don't infect later operands. |
| 317 | if (IsDistinct) |
Teresa Johnson | b703c77 | 2016-03-29 18:24:19 +0000 | [diff] [blame] | 318 | resolveCycles(New); |
Duncan P. N. Exon Smith | 6dc22bf | 2015-01-19 22:44:32 +0000 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
| 322 | return AnyChanged; |
| 323 | } |
| 324 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 325 | Metadata *Mapper::mapDistinctNode(const MDNode *Node) { |
Duncan P. N. Exon Smith | 14cc94c | 2015-01-14 01:03:05 +0000 | [diff] [blame] | 326 | assert(Node->isDistinct() && "Expected distinct node"); |
| 327 | |
Duncan P. N. Exon Smith | 4fb46cb | 2015-08-03 17:09:38 +0000 | [diff] [blame] | 328 | MDNode *NewMD; |
| 329 | if (Flags & RF_MoveDistinctMDs) |
| 330 | NewMD = const_cast<MDNode *>(Node); |
| 331 | else |
| 332 | NewMD = MDNode::replaceWithDistinct(Node->clone()); |
Duncan P. N. Exon Smith | 920df5c | 2015-02-04 19:44:34 +0000 | [diff] [blame] | 333 | |
Duncan P. N. Exon Smith | 3115f75 | 2015-08-05 23:52:42 +0000 | [diff] [blame] | 334 | // Remap operands later. |
| 335 | DistinctWorklist.push_back(NewMD); |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 336 | return mapToMetadata(Node, NewMD); |
Duncan P. N. Exon Smith | fb9d128 | 2015-01-14 01:08:47 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 339 | Metadata *Mapper::mapUniquedNode(const MDNode *Node) { |
Teresa Johnson | b703c77 | 2016-03-29 18:24:19 +0000 | [diff] [blame] | 340 | assert(Node->isUniqued() && "Expected uniqued node"); |
Duncan P. N. Exon Smith | b557989 | 2015-01-14 01:06:21 +0000 | [diff] [blame] | 341 | |
Duncan P. N. Exon Smith | 2705097 | 2015-08-05 23:22:34 +0000 | [diff] [blame] | 342 | // Create a temporary node and map it upfront in case we have a uniquing |
| 343 | // cycle. If necessary, this mapping will get updated by RAUW logic before |
| 344 | // returning. |
Duncan P. N. Exon Smith | 03e0583 | 2015-01-20 02:56:57 +0000 | [diff] [blame] | 345 | auto ClonedMD = Node->clone(); |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 346 | mapToMetadata(Node, ClonedMD.get()); |
| 347 | if (!remapOperands(*ClonedMD)) { |
Duncan P. N. Exon Smith | 2705097 | 2015-08-05 23:22:34 +0000 | [diff] [blame] | 348 | // No operands changed, so use the original. |
Duncan P. N. Exon Smith | 706f37e | 2015-08-04 06:42:31 +0000 | [diff] [blame] | 349 | ClonedMD->replaceAllUsesWith(const_cast<MDNode *>(Node)); |
Teresa Johnson | b703c77 | 2016-03-29 18:24:19 +0000 | [diff] [blame] | 350 | return const_cast<MDNode *>(Node); |
Duncan P. N. Exon Smith | 706f37e | 2015-08-04 06:42:31 +0000 | [diff] [blame] | 351 | } |
Duncan P. N. Exon Smith | 0dcffe2 | 2015-01-19 22:39:07 +0000 | [diff] [blame] | 352 | |
Teresa Johnson | b703c77 | 2016-03-29 18:24:19 +0000 | [diff] [blame] | 353 | // Uniquify the cloned node. |
| 354 | return MDNode::replaceWithUniqued(std::move(ClonedMD)); |
Duncan P. N. Exon Smith | b557989 | 2015-01-14 01:06:21 +0000 | [diff] [blame] | 355 | } |
| 356 | |
Duncan P. N. Exon Smith | ae8bd4b | 2016-04-03 19:31:01 +0000 | [diff] [blame] | 357 | Optional<Metadata *> Mapper::mapSimpleMetadata(const Metadata *MD) { |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 358 | // If the value already exists in the map, use it. |
Duncan P. N. Exon Smith | da4a56d | 2016-04-02 17:04:38 +0000 | [diff] [blame] | 359 | if (Optional<Metadata *> NewMD = VM.getMappedMD(MD)) |
| 360 | return *NewMD; |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 361 | |
| 362 | if (isa<MDString>(MD)) |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 363 | return mapToSelf(MD); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 364 | |
| 365 | if (isa<ConstantAsMetadata>(MD)) |
| 366 | if ((Flags & RF_NoModuleLevelChanges)) |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 367 | return mapToSelf(MD); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 368 | |
| 369 | if (const auto *VMD = dyn_cast<ValueAsMetadata>(MD)) { |
Duncan P. N. Exon Smith | 756e1c3 | 2016-04-03 20:54:51 +0000 | [diff] [blame] | 370 | // Disallow recursion into metadata mapping through mapValue. |
| 371 | VM.disableMapMetadata(); |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 372 | Value *MappedV = mapValue(VMD->getValue()); |
Duncan P. N. Exon Smith | 756e1c3 | 2016-04-03 20:54:51 +0000 | [diff] [blame] | 373 | VM.enableMapMetadata(); |
| 374 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 375 | if (VMD->getValue() == MappedV || |
| 376 | (!MappedV && (Flags & RF_IgnoreMissingEntries))) |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 377 | return mapToSelf(MD); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 378 | |
Duncan P. N. Exon Smith | 8e65f8d | 2016-04-04 04:59:56 +0000 | [diff] [blame^] | 379 | return mapToMetadata(MD, MappedV ? ValueAsMetadata::get(MappedV) : nullptr); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 380 | } |
| 381 | |
Duncan P. N. Exon Smith | ae8bd4b | 2016-04-03 19:31:01 +0000 | [diff] [blame] | 382 | assert(isa<MDNode>(MD) && "Expected a metadata node"); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 383 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 384 | // If this is a module-level metadata and we know that nothing at the |
| 385 | // module level is changing, then use an identity mapping. |
| 386 | if (Flags & RF_NoModuleLevelChanges) |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 387 | return mapToSelf(MD); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 388 | |
Duncan P. N. Exon Smith | ae8bd4b | 2016-04-03 19:31:01 +0000 | [diff] [blame] | 389 | return None; |
| 390 | } |
| 391 | |
| 392 | Metadata *Mapper::mapMetadataImpl(const Metadata *MD) { |
Duncan P. N. Exon Smith | 756e1c3 | 2016-04-03 20:54:51 +0000 | [diff] [blame] | 393 | assert(VM.mayMapMetadata() && "Unexpected co-recursion through mapValue"); |
Duncan P. N. Exon Smith | ae8bd4b | 2016-04-03 19:31:01 +0000 | [diff] [blame] | 394 | if (Optional<Metadata *> NewMD = mapSimpleMetadata(MD)) |
| 395 | return *NewMD; |
| 396 | |
Duncan P. N. Exon Smith | 170c26d | 2015-03-17 01:14:40 +0000 | [diff] [blame] | 397 | // Require resolved nodes whenever metadata might be remapped. |
Duncan P. N. Exon Smith | ae8bd4b | 2016-04-03 19:31:01 +0000 | [diff] [blame] | 398 | auto *Node = cast<MDNode>(MD); |
Teresa Johnson | b703c77 | 2016-03-29 18:24:19 +0000 | [diff] [blame] | 399 | assert(Node->isResolved() && "Unexpected unresolved node"); |
Duncan P. N. Exon Smith | 170c26d | 2015-03-17 01:14:40 +0000 | [diff] [blame] | 400 | |
Duncan P. N. Exon Smith | 14cc94c | 2015-01-14 01:03:05 +0000 | [diff] [blame] | 401 | if (Node->isDistinct()) |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 402 | return mapDistinctNode(Node); |
Duncan P. N. Exon Smith | 953e1a4 | 2015-01-08 22:42:30 +0000 | [diff] [blame] | 403 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 404 | return mapUniquedNode(Node); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 405 | } |
| 406 | |
Duncan P. N. Exon Smith | 46d7af5 | 2014-12-19 06:06:18 +0000 | [diff] [blame] | 407 | Metadata *llvm::MapMetadata(const Metadata *MD, ValueToValueMapTy &VM, |
| 408 | RemapFlags Flags, ValueMapTypeRemapper *TypeMapper, |
| 409 | ValueMaterializer *Materializer) { |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 410 | return Mapper(VM, Flags, TypeMapper, Materializer).mapMetadata(MD); |
| 411 | } |
| 412 | |
| 413 | Metadata *Mapper::mapMetadata(const Metadata *MD) { |
| 414 | Metadata *NewMD = mapMetadataImpl(MD); |
Duncan P. N. Exon Smith | 920df5c | 2015-02-04 19:44:34 +0000 | [diff] [blame] | 415 | |
Duncan P. N. Exon Smith | 3115f75 | 2015-08-05 23:52:42 +0000 | [diff] [blame] | 416 | // When there are no module-level changes, it's possible that the metadata |
| 417 | // graph has temporaries. Skip the logic to resolve cycles, since it's |
| 418 | // unnecessary (and invalid) in that case. |
| 419 | if (Flags & RF_NoModuleLevelChanges) |
Duncan P. N. Exon Smith | 4fb46cb | 2015-08-03 17:09:38 +0000 | [diff] [blame] | 420 | return NewMD; |
Duncan P. N. Exon Smith | 920df5c | 2015-02-04 19:44:34 +0000 | [diff] [blame] | 421 | |
Duncan P. N. Exon Smith | c9fdbdb | 2015-08-07 00:39:26 +0000 | [diff] [blame] | 422 | // Resolve cycles involving the entry metadata. |
Teresa Johnson | b703c77 | 2016-03-29 18:24:19 +0000 | [diff] [blame] | 423 | resolveCycles(NewMD); |
Duncan P. N. Exon Smith | 4fb46cb | 2015-08-03 17:09:38 +0000 | [diff] [blame] | 424 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 425 | return NewMD; |
| 426 | } |
| 427 | |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 428 | Mapper::~Mapper() { |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 429 | // Remap the operands of distinct MDNodes. |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 430 | while (!DistinctWorklist.empty()) |
| 431 | remapOperands(*DistinctWorklist.pop_back_val()); |
Duncan P. N. Exon Smith | c6065e3 | 2016-04-03 20:17:45 +0000 | [diff] [blame] | 432 | |
| 433 | // Materialize global initializers. |
| 434 | while (!DelayedInits.empty()) { |
| 435 | auto Init = DelayedInits.pop_back_val(); |
| 436 | Materializer->materializeInitFor(Init.New, Init.Old); |
| 437 | } |
| 438 | |
| 439 | // Process block addresses delayed until global inits. |
| 440 | while (!DelayedBBs.empty()) { |
| 441 | DelayedBasicBlock DBB = DelayedBBs.pop_back_val(); |
| 442 | BasicBlock *BB = cast_or_null<BasicBlock>(mapValue(DBB.OldBB)); |
| 443 | DBB.TempBB->replaceAllUsesWith(BB ? BB : DBB.OldBB); |
| 444 | } |
| 445 | |
| 446 | // We don't expect any of these to grow after clearing. |
| 447 | assert(DistinctWorklist.empty()); |
| 448 | assert(DelayedInits.empty()); |
| 449 | assert(DelayedBBs.empty()); |
Duncan P. N. Exon Smith | 829dc87 | 2016-04-03 19:06:24 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Duncan P. N. Exon Smith | 46d7af5 | 2014-12-19 06:06:18 +0000 | [diff] [blame] | 452 | MDNode *llvm::MapMetadata(const MDNode *MD, ValueToValueMapTy &VM, |
| 453 | RemapFlags Flags, ValueMapTypeRemapper *TypeMapper, |
| 454 | ValueMaterializer *Materializer) { |
Duncan P. N. Exon Smith | da4a56d | 2016-04-02 17:04:38 +0000 | [diff] [blame] | 455 | return cast_or_null<MDNode>(MapMetadata(static_cast<const Metadata *>(MD), VM, |
| 456 | Flags, TypeMapper, Materializer)); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 457 | } |
| 458 | |
Brian Gaeke | 6182acf | 2004-05-19 09:08:12 +0000 | [diff] [blame] | 459 | /// RemapInstruction - Convert the instruction operands from referencing the |
Devang Patel | b8f11de | 2010-06-23 23:55:51 +0000 | [diff] [blame] | 460 | /// current values into those specified by VMap. |
Brian Gaeke | 6182acf | 2004-05-19 09:08:12 +0000 | [diff] [blame] | 461 | /// |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 462 | void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap, |
James Molloy | f6f121e | 2013-05-28 15:17:05 +0000 | [diff] [blame] | 463 | RemapFlags Flags, ValueMapTypeRemapper *TypeMapper, |
| 464 | ValueMaterializer *Materializer){ |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 465 | // Remap operands. |
Gabor Greif | 5df4326 | 2008-05-30 21:24:22 +0000 | [diff] [blame] | 466 | for (User::op_iterator op = I->op_begin(), E = I->op_end(); op != E; ++op) { |
James Molloy | f6f121e | 2013-05-28 15:17:05 +0000 | [diff] [blame] | 467 | Value *V = MapValue(*op, VMap, Flags, TypeMapper, Materializer); |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 468 | // If we aren't ignoring missing entries, assert that something happened. |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 469 | if (V) |
Chris Lattner | 43f8d16 | 2011-01-08 08:15:20 +0000 | [diff] [blame] | 470 | *op = V; |
| 471 | else |
| 472 | assert((Flags & RF_IgnoreMissingEntries) && |
| 473 | "Referenced value not in value map!"); |
Brian Gaeke | 6182acf | 2004-05-19 09:08:12 +0000 | [diff] [blame] | 474 | } |
Daniel Dunbar | 95fe13c | 2010-08-26 03:48:08 +0000 | [diff] [blame] | 475 | |
Jay Foad | 61ea0e4 | 2011-06-23 09:09:15 +0000 | [diff] [blame] | 476 | // Remap phi nodes' incoming blocks. |
| 477 | if (PHINode *PN = dyn_cast<PHINode>(I)) { |
| 478 | for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { |
| 479 | Value *V = MapValue(PN->getIncomingBlock(i), VMap, Flags); |
| 480 | // If we aren't ignoring missing entries, assert that something happened. |
Craig Topper | f40110f | 2014-04-25 05:29:35 +0000 | [diff] [blame] | 481 | if (V) |
Jay Foad | 61ea0e4 | 2011-06-23 09:09:15 +0000 | [diff] [blame] | 482 | PN->setIncomingBlock(i, cast<BasicBlock>(V)); |
| 483 | else |
| 484 | assert((Flags & RF_IgnoreMissingEntries) && |
| 485 | "Referenced block not in value map!"); |
| 486 | } |
| 487 | } |
| 488 | |
Devang Patel | c017404 | 2011-08-04 20:02:18 +0000 | [diff] [blame] | 489 | // Remap attached metadata. |
Duncan P. N. Exon Smith | de36e80 | 2014-11-11 21:30:22 +0000 | [diff] [blame] | 490 | SmallVector<std::pair<unsigned, MDNode *>, 4> MDs; |
Devang Patel | c017404 | 2011-08-04 20:02:18 +0000 | [diff] [blame] | 491 | I->getAllMetadata(MDs); |
Duncan P. N. Exon Smith | e08bcbf | 2015-08-03 03:27:12 +0000 | [diff] [blame] | 492 | for (const auto &MI : MDs) { |
| 493 | MDNode *Old = MI.second; |
Duncan P. N. Exon Smith | 46d7af5 | 2014-12-19 06:06:18 +0000 | [diff] [blame] | 494 | MDNode *New = MapMetadata(Old, VMap, Flags, TypeMapper, Materializer); |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 495 | if (New != Old) |
Duncan P. N. Exon Smith | e08bcbf | 2015-08-03 03:27:12 +0000 | [diff] [blame] | 496 | I->setMetadata(MI.first, New); |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 497 | } |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 498 | |
David Blaikie | 348de69 | 2015-04-23 21:36:23 +0000 | [diff] [blame] | 499 | if (!TypeMapper) |
| 500 | return; |
| 501 | |
Chris Lattner | b1ed91f | 2011-07-09 17:41:24 +0000 | [diff] [blame] | 502 | // If the instruction's type is being remapped, do so now. |
David Blaikie | 348de69 | 2015-04-23 21:36:23 +0000 | [diff] [blame] | 503 | if (auto CS = CallSite(I)) { |
| 504 | SmallVector<Type *, 3> Tys; |
| 505 | FunctionType *FTy = CS.getFunctionType(); |
| 506 | Tys.reserve(FTy->getNumParams()); |
| 507 | for (Type *Ty : FTy->params()) |
| 508 | Tys.push_back(TypeMapper->remapType(Ty)); |
| 509 | CS.mutateFunctionType(FunctionType::get( |
| 510 | TypeMapper->remapType(I->getType()), Tys, FTy->isVarArg())); |
David Blaikie | bf0a42a | 2015-04-29 23:00:35 +0000 | [diff] [blame] | 511 | return; |
| 512 | } |
| 513 | if (auto *AI = dyn_cast<AllocaInst>(I)) |
| 514 | AI->setAllocatedType(TypeMapper->remapType(AI->getAllocatedType())); |
David Blaikie | f5147ef | 2015-06-01 03:09:34 +0000 | [diff] [blame] | 515 | if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) { |
David Blaikie | 73cf872 | 2015-05-05 18:03:48 +0000 | [diff] [blame] | 516 | GEP->setSourceElementType( |
| 517 | TypeMapper->remapType(GEP->getSourceElementType())); |
David Blaikie | f5147ef | 2015-06-01 03:09:34 +0000 | [diff] [blame] | 518 | GEP->setResultElementType( |
| 519 | TypeMapper->remapType(GEP->getResultElementType())); |
| 520 | } |
David Blaikie | bf0a42a | 2015-04-29 23:00:35 +0000 | [diff] [blame] | 521 | I->mutateType(TypeMapper->remapType(I->getType())); |
Dan Gohman | ca26f79 | 2010-08-26 15:41:53 +0000 | [diff] [blame] | 522 | } |