This is an archive of the discontinued LLVM Phabricator instance.

Safely generate new loop metadata node
ClosedPublic

Authored by dpeixott on Nov 7 2014, 11:19 AM.

Details

Summary

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).

Diff Detail

Repository
rL LLVM

Event Timeline

dpeixott updated this revision to Diff 15934.Nov 7 2014, 11:19 AM
dpeixott retitled this revision from to Safely generate new loop metadata node.
dpeixott added reviewers: jdoerfert, grosser, zinob.
dpeixott updated this object.
dpeixott added a subscriber: Unknown Object (MLST).
jdoerfert accepted this revision.Nov 7 2014, 11:26 AM
jdoerfert edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 7 2014, 11:26 AM
dpeixott closed this revision.Nov 7 2014, 1:55 PM
dpeixott updated this revision to Diff 15939.

Closed by commit rL221550 (authored by @dpeixott).