This is an archive of the discontinued LLVM Phabricator instance.

Avoid shuffle self-assignment in EXPENSIVE_CHECKS builds
ClosedPublic

Authored by arichardson on Mar 8 2021, 3:43 AM.

Details

Summary

Some versions of libstdc++ perform self-assignment in std::shuffle. This
breaks the EXPENSIVE_CHECKS builds of TableGen due to an incorrect assertion
in libstdc++.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85828.

Fixes https://llvm.org/PR37652

Diff Detail

Event Timeline

arichardson created this revision.Mar 8 2021, 3:43 AM
arichardson requested review of this revision.Mar 8 2021, 3:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2021, 3:43 AM

It seems like https://bugs.llvm.org/show_bug.cgi?id=37652 was fixed upstream.
Do we still want to workaround it?

llvm/include/llvm/ADT/STLExtras.h
1339

This should have a comment explaining why this is needed

It seems like https://bugs.llvm.org/show_bug.cgi?id=37652 was fixed upstream.
Do we still want to workaround it?

It appears that https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85828 was fixed Aug2020, so most Linux distributions still ship a libstdc++ with the assert unless they backported the fix. I think it probably makes sense to work around it.

llvm/include/llvm/ADT/STLExtras.h
1339

Will add a comment if we are happy to proceed with this patch.
How about the following?

nikic added a comment.Mar 8 2021, 5:12 AM

This looks reasonable to me. I can also confirm that EXPENSIVE_CHECKS with libstdc++-10 successfully builds after this patch. Presumably the not yet released libstdc++-11 would work without it.

RKSimon added inline comments.Mar 9 2021, 10:57 AM
llvm/include/llvm/ADT/STLExtras.h
1339

Yes that sounds ok to me

  • Add comment explaining != 0 check
RKSimon accepted this revision.Mar 9 2021, 11:11 AM

LGTM - cheers

This revision is now accepted and ready to land.Mar 9 2021, 11:11 AM
This revision was landed with ongoing or failed builds.Mar 10 2021, 3:18 AM
This revision was automatically updated to reflect the committed changes.