[PATCH] Safely generate new loop metadata node

David Peixotto dpeixott at codeaurora.org
Fri Nov 7 11:19:13 PST 2014


Hi jdoerfert, grosser, zinob,

Polly was accidently modifying a debug info metadata node when
attempting to generate a new unique metadata node for the loop id.
The problem was that we had dwarf metadata that referred to a
metadata node with a null value, like this:

  !6 = ... some dwarf metadata referring to !7 ...
  !7 = {null}

When we attempt to generate a new metadata node, we reserve the
first space for self-referential node by setting the first argument
to null and then mutating the node later to refer to itself.
However, because the nodes are uniqued based on pointer values, when
we get the new metadata node it actually referred to an existing
node (!7 in the example).  When we went to modify the metadata to
point to itself, we were accidently mutating the dwarf metatdata. We
ended up in this situation:

  !6 = ... some dwarf metadata referring to !7 ...
  !7 = {!7}

and this causes an assert when generating the debug info. The fix is
simple, we just need to use a unique value when getting a new
metadata node. The MDNode::getTemporary() provides exactly the API
we need (and it is used in clang to generate the unique nodes).

http://reviews.llvm.org/D6174

Files:
  lib/CodeGen/IRBuilder.cpp
  test/Isl/CodeGen/LoopParallelMD/do_not_mutate_debug_info.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6174.15934.patch
Type: text/x-patch
Size: 5434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141107/dfaa953e/attachment.bin>


More information about the llvm-commits mailing list