<div dir="ltr">Is it OK to remove metadata in an optimization pass?  The context is patch <a href="http://reviews.llvm.org/D4571">http://reviews.llvm.org/D4571</a> which removes loop unrolling hint metadata after using it to avoid unrolling more than the hint suggests.  This is a potential problem because loop unrolling can be run more than once.  Example: a loop annotated with "#pragma clang loop unroll_count(2)" which adds hint metadata to the loop would be unrolled twice every time the loop unrolling pass is run.  Anyway, I ask about metadata removal because Eli who is reviewing the patch wasn't sure whether this was acceptable.<div>
<br></div><div>Loop unrolling metadata can take the following forms:</div><div>llvm.loop.unroll.enable false  // don't unroll</div><div>llvm.loop.unroll.enable true  // try to fully unroll</div><div>llvm.loop.unroll.count N  // try to unroll N times</div>
<div><br></div><div>An alternative implementation to deleting nodes would be to just add a "llvm.loop.unroll.enable false" metadata node after unrolling.  It's a little funny because you could then have, say, both "llvm.loop.unroll.enable false" and "llvm.loop.unroll.enable true" attached to a loop which is a bit funny.  Yet another alternative is to make up some new metadata node type like "llvm.loop.unroll.already_unrolled" and add it to the loop.</div>
<div><br></div><div><div><div>Mark</div></div></div></div>