[LLVMdev] Removing metadata in a pass

Mark Heffernan meheff at google.com
Thu Jul 17 14:48:04 PDT 2014


Is it OK to remove metadata in an optimization pass?  The context is patch
http://reviews.llvm.org/D4571 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.

Loop unrolling metadata can take the following forms:
llvm.loop.unroll.enable false  // don't unroll
llvm.loop.unroll.enable true  // try to fully unroll
llvm.loop.unroll.count N  // try to unroll N times

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.

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140717/1e7a68e1/attachment.html>


More information about the llvm-dev mailing list