Skip to content

Commit

Permalink
Utils: Use helper function directly, NFC
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225901 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dexonsmith committed Jan 14, 2015
1 parent f82fc00 commit 874f377
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/Transforms/Utils/ValueMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ static Metadata *MapMetadataImpl(const Metadata *MD, ValueToValueMapTy &VM,
const MDNode *Node = cast<MDNode>(MD);
assert(Node->isResolved() && "Unexpected unresolved node");

auto getMappedOp = [&](Metadata *Op) -> Metadata *{
return mapMetadataOp(Op, VM, Flags, TypeMapper, Materializer);
};

// If this is a module-level metadata and we know that nothing at the
// module level is changing, then use an identity mapping.
if (Flags & RF_NoModuleLevelChanges)
Expand All @@ -233,7 +229,8 @@ static Metadata *MapMetadataImpl(const Metadata *MD, ValueToValueMapTy &VM,

// Fix the operands.
for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I)
NewMD->replaceOperandWith(I, getMappedOp(Node->getOperand(I)));
NewMD->replaceOperandWith(I, mapMetadataOp(Node->getOperand(I), VM, Flags,
TypeMapper, Materializer));

return NewMD;
}
Expand All @@ -245,15 +242,16 @@ static Metadata *MapMetadataImpl(const Metadata *MD, ValueToValueMapTy &VM,
// Check all operands to see if any need to be remapped.
for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I) {
Metadata *Op = Node->getOperand(I);
Metadata *MappedOp = getMappedOp(Op);
Metadata *MappedOp = mapMetadataOp(Op, VM, Flags, TypeMapper, Materializer);
if (Op == MappedOp)
continue;

// Ok, at least one operand needs remapping.
SmallVector<Metadata *, 4> Elts;
Elts.reserve(Node->getNumOperands());
for (I = 0; I != E; ++I)
Elts.push_back(getMappedOp(Node->getOperand(I)));
Elts.push_back(mapMetadataOp(Node->getOperand(I), VM, Flags, TypeMapper,
Materializer));

MDNode *NewMD = MDTuple::get(Node->getContext(), Elts);
Dummy->replaceAllUsesWith(NewMD);
Expand Down

0 comments on commit 874f377

Please sign in to comment.