[PATCH] D90079: CGLoopInfo: Avoid unnecessary uses of `MDNode::getTemporary`, NFC

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 15:19:25 PDT 2020


dexonsmith created this revision.
dexonsmith added reviewers: dblaikie, aprantl.
Herald added a reviewer: bollu.
Herald added subscribers: ributzka, hiraditya, kristof.beyls.
Herald added a project: LLVM.
dexonsmith requested review of this revision.

`TempMDNode` includes a bunch of machinery for RAUW, and should only be
used when necessary. RAUW wasn't being used in any of these cases... it
was just a placeholder for a self-reference.

Where the real node was using `MDNode::getDistinct`, just replace the
temporary argument with `nullptr`.

Where the real node was using `MDNode::get`, the `replaceOperandWith`
call was "promoting" the node to a distinct one implicitly due to
self-reference detection in `MDNode::handleChangedOperand`. The
`TempMDNode` was serving a purpose by delaying uniquing, but it's way
simpler to just call `MDNode::getDistinct` in the first place.

Note that using a self-reference at all in these places is a hold-over
from before `distinct` metadata existed. It was an old trick to create
distinct nodes. It would be intrusive to change, including bitcode
upgrades, etc., and it's harmless so I'm not sure there's much value in
removing it from existing schemas. After this commit it still has a tiny
memory cost (in the extra metadata operand) but no more overhead in
construction.


https://reviews.llvm.org/D90079

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/IR/MDBuilder.cpp
  polly/lib/CodeGen/IRBuilder.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90079.300422.patch
Type: text/x-patch
Size: 6074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201023/1cf4d964/attachment.bin>


More information about the llvm-commits mailing list