This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ] Fix check for zero size when lowering memcmp.
ClosedPublic

Authored by Kai on Jun 2 2022, 10:56 AM.

Details

Summary

During lowering of memcmp/bcmp, the check for a size of 0 is done in 2 different ways.
In rare cases this can lead to a crash in SystemZSelectionDAGInfo::EmitTargetCodeForMemcmp().
The root cause is that SelectionDAGBuilder::visitMemCmpBCmpCall() checks for a constant int value which is not yet evaluated. When the value is turned into a SDValue, then the evaluation is done and results in a ConstantSDNode. EmitTargetCodeForMemcmp() expect the special case of 0 length to be handled, which results in an assertion.

The fix is to turn the value into a SDValue, so that both functions use the same check.

Diff Detail

Event Timeline

Kai created this revision.Jun 2 2022, 10:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2022, 10:56 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Kai requested review of this revision.Jun 2 2022, 10:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2022, 10:56 AM
uweigand accepted this revision.Jun 8 2022, 7:24 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jun 8 2022, 7:24 AM
This revision was landed with ongoing or failed builds.Jun 8 2022, 11:52 AM
This revision was automatically updated to reflect the committed changes.