This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Prevent non-determinism when updating DIArgList users of a value
ClosedPublic

Authored by StephenTozer on Jun 11 2021, 3:47 AM.

Details

Summary

This patch fixes the most recent issue mentioned in the discussion for patch D91722, in which some builds had non-deterministic output. This bug is rooted in ReplaceableMetadataImpl::getAllArgListUsers, which returns a vector of Metadata*; this vector is built by iterating over a map, and the result is later used to modify/produce instructions. This patch uses the IDs associated with each user to ensure that the vector is deterministically ordered; there is no importance to the ordering itself, other than that it is deterministic.

Diff Detail

Event Timeline

StephenTozer created this revision.Jun 11 2021, 3:47 AM
StephenTozer requested review of this revision.Jun 11 2021, 3:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2021, 3:47 AM
rnk accepted this revision.Jun 11 2021, 4:37 PM
rnk added a subscriber: rnk.

Thanks for finding this, I think it looks good.

llvm/lib/IR/Metadata.cpp
199

This is a bit pedantic, but it seems like it could be less code to build a vector of pointers to pairs in the DenseMap, sort those pointers to pairs, and then extract the owners afterwards. Fewer new pairs with new implied meanings of .second, that sort of thing.

This revision is now accepted and ready to land.Jun 11 2021, 4:37 PM
StephenTozer added inline comments.Jun 14 2021, 3:44 AM
llvm/lib/IR/Metadata.cpp
199

I tried implementing this, but in this case it doesn't look to make the code any less verbose or easier to read in my opinion (see below).

199–214
This revision was landed with ongoing or failed builds.Jun 17 2021, 7:09 AM
This revision was automatically updated to reflect the committed changes.