This is an archive of the discontinued LLVM Phabricator instance.

[MergeICmps] Don't merge icmps derived from pointers with addressspaces
ClosedPublic

Authored by vchuravy on Jan 15 2021, 11:12 AM.

Details

Summary

IIUC we can't emit memcmp between pointers in addressspaces,
doing so will trigger an assertion since the signature of the memcmp
will not match it's arguments (https://bugs.llvm.org/show_bug.cgi?id=48661).

This PR disables the attempt to merge icmps,
when the pointer is in an addressspace.

Diff Detail

Event Timeline

vchuravy created this revision.Jan 15 2021, 11:12 AM
vchuravy requested review of this revision.Jan 15 2021, 11:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 15 2021, 11:12 AM
vchuravy added a reviewer: Restricted Project.Jan 15 2021, 11:12 AM
vchuravy added a subscriber: Restricted Project.
vchuravy retitled this revision from [MergeICmps] Don't merge icmps derived frm pointers with addressspaces to [MergeICmps] Don't merge icmps derived from pointers with addressspaces.Jan 15 2021, 2:27 PM
MaskRay added inline comments.Jan 25 2021, 8:34 PM
llvm/test/Transforms/MergeICmps/addressspaces.ll
2 ↗(On Diff #317030)

Add a file-level header about the purpose.

8 ↗(On Diff #317030)

Nit: Use named arguments and values. You could use gep-references-bb.ll as an example. I took some time to write meaningful names.

47 ↗(On Diff #317030)

Nit: Replace the labels with more meaningful ones.

64 ↗(On Diff #317030)

Delete unused metadata.

For such negative tests, they can easily get stale. Adding them into an existing positive test and tweaking the existing test may be a good way to prevent bit rot, but I don't know which existing test is suitable.

vtjnash accepted this revision.Feb 8 2021, 3:29 PM
vtjnash added a subscriber: vtjnash.

LGTM, modulo comments from previous reviewer

This revision is now accepted and ready to land.Feb 8 2021, 3:29 PM
vchuravy updated this revision to Diff 369168.Aug 27 2021, 1:14 PM

Improve and simplify test

This revision was landed with ongoing or failed builds.Aug 27 2021, 1:15 PM
This revision was automatically updated to reflect the committed changes.
arichardson added inline comments.
llvm/lib/Transforms/Scalar/MergeICmps.cpp
148

In the CHERI-enabled targets (for Aarch64,RISC-V and MIPS) memcmp takes addrspace(200) arguments. Would it be possible to use the memcmp signature instead of a hardcoded AS0 check?

vchuravy added inline comments.Aug 28 2021, 4:10 AM
llvm/lib/Transforms/Scalar/MergeICmps.cpp
148

Possibly, could you send me a reproducer/test case? I couldn't find any example in the test suite for memcmp with different AS.