diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-08-03 03:45:32 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-08-03 03:45:32 +0000 |
commit | 50f8969e52f29f85a5dec407daf4e236dd6ce0a8 (patch) | |
tree | 3638ec968604603d8416be82bdcada7a2503cb60 /llvm/lib/Transforms/Utils/ValueMapper.cpp | |
parent | e08bcbff8f18f2016bd66f0321f51b3e7e279fc6 (diff) | |
download | llvm-50f8969e52f29f85a5dec407daf4e236dd6ce0a8.zip llvm-50f8969e52f29f85a5dec407daf4e236dd6ce0a8.tar.gz llvm-50f8969e52f29f85a5dec407daf4e236dd6ce0a8.tar.bz2 |
ValueMapper: Only check for cycles if operands change
This is a minor optimization to only check for unresolved operands
inside `mapDistinctNode()` if the operands have actually changed. This
shouldn't really cause any change in behaviour. I didn't actually see a
slowdown in a profile, I was just poking around nearby and saw the
opportunity.
llvm-svn: 243866
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 2de1928..8daf546 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -227,13 +227,14 @@ static Metadata *mapDistinctNode(const MDNode *Node, assert(Node->isDistinct() && "Expected distinct node"); MDNode *NewMD = MDNode::replaceWithDistinct(Node->clone()); - remap(Node, NewMD, Cycles, VM, Flags, TypeMapper, Materializer); - // Track any cycles beneath this node. - for (Metadata *Op : NewMD->operands()) - if (auto *Node = dyn_cast_or_null<MDNode>(Op)) - if (!Node->isResolved()) - Cycles.push_back(Node); + // Remap the operands. If any change, track those that could be involved in + // uniquing cycles. + if (remap(Node, NewMD, Cycles, VM, Flags, TypeMapper, Materializer)) + for (Metadata *Op : NewMD->operands()) + if (auto *Node = dyn_cast_or_null<MDNode>(Op)) + if (!Node->isResolved()) + Cycles.push_back(Node); return NewMD; } |