This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Fix some test failures with EXPENSIVE_CHECKS and libstdc++
ClosedPublic

Authored by DavidSpickett on Jul 20 2022, 3:01 AM.

Details

Summary

DebugLocEntry assumes that it either contains 1 item that has no fragment
or many items that all have fragments (see the assert in addValues).

When EXPENSIVE_CHECKS is enabled, _GLIBCXX_DEBUG is defined. On a few machines
I've checked, this causes std::sort to call the comparator even
if there is only 1 item to sort. Perhaps to check that it is implemented
properly ordering wise, I didn't find out exactly why.

operator< for a DbgValueLoc will crash if this happens because the
optional Fragment is empty.

Compiler/linker/optimisation level seems to make this happen
or not. So I've seen this happen on x86 Ubuntu but the buildbot
for release EXPENSIVE_CHECKS did not have this issue.

Add an explicit check whether we have 1 item.

Diff Detail

Event Timeline

DavidSpickett created this revision.Jul 20 2022, 3:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 3:01 AM
DavidSpickett requested review of this revision.Jul 20 2022, 3:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 3:01 AM
DavidSpickett edited the summary of this revision. (Show Details)Jul 20 2022, 3:02 AM

Shoud we just leave the check in unconditionally as an optimization?

llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
220

presumably

Always check for 1 item.

DavidSpickett edited the summary of this revision. (Show Details)Jul 27 2022, 2:00 AM
aprantl accepted this revision.Jul 27 2022, 1:22 PM
This revision is now accepted and ready to land.Jul 27 2022, 1:22 PM
This revision was landed with ongoing or failed builds.Jul 28 2022, 1:53 AM
This revision was automatically updated to reflect the committed changes.