This is an archive of the discontinued LLVM Phabricator instance.

Fix assertions on lazy-loading of Metadata TBAA attachments
ClosedPublic

Authored by mehdi_amini on Jan 6 2017, 4:59 PM.

Details

Summary

The issue happens with:

%0 = ....., !tbaa !0
%1 = ....., !tbaa !1

With !0 that references !1.

In this case when loading !0 we generates a temporary for the
operand !1. We now flush it immediately and trigger the load of
!1 before moving on. If we don't we get the temporary when
attaching to %1. This is usually not an issue except that we
eagerly try to update TBAA MDNodes, which is obviously not possible
if we only have a temporary.

Event Timeline

mehdi_amini updated this revision to Diff 83466.Jan 6 2017, 4:59 PM
mehdi_amini retitled this revision from to Fix assertions on lazy-loading of Metadata TBAA attachments.
mehdi_amini updated this object.
mehdi_amini added reviewers: tejohnson, pcc.
mehdi_amini added a subscriber: llvm-commits.
tejohnson accepted this revision.Jan 7 2017, 8:07 AM
tejohnson edited edge metadata.

LGTM as a bug fix. But I have a few general questions below.

llvm/lib/Bitcode/Reader/MetadataLoader.cpp
704

I just noticed that Placeholders is never used in lazyLoadModuleMetadataBlock, so it should probably be removed (in a follow up patch). It does create forward refs so I guess resolveForwardRefsAndPlaceholders below still needs to be invoked, but should it be invoked from within lazyLoadModuleMetadataBlock instead (and passed a dummy PlaceholdersQueue)?

1613

I suppose there is no loss in doing this more frequently since we know we need to resolve these anyway? Is there any disadvantage to doing the resolveForwardRefsAndPlaceholders more frequently? If so, should it only be done for TBAA attachments? If not, then should we be doing it more frequently elsewhere?

This revision is now accepted and ready to land.Jan 7 2017, 8:07 AM
mehdi_amini added inline comments.Jan 7 2017, 12:06 PM
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
1613

I'm looking into this, especially because since committing the lazy-loading I don't reproduce the improvements I had on my early version. I likely fixed a bug between my prototype and the final version.
I have >10% of the *total* link time spent in RAUW MDNodes.

This revision was automatically updated to reflect the committed changes.