This is an archive of the discontinued LLVM Phabricator instance.

Enabling the copy-constant-to-alloca optimization in more instances
ClosedPublic

Authored by mfawaz on Jul 22 2021, 10:10 AM.

Details

Summary

This patch allows lifetime calls to be ignored (and later erased) if we
know that the copy-constant-to-alloca optimization is going to happen.
The case that is missed is when the global variable is in a different address
space than the alloca (as shown in the example added to the lit test.)

This used to work before https://github.com/llvm/llvm-project/commit/6da31fa4a61d68af21dfa1e144e726ed6d77903e

Diff Detail

Event Timeline

mfawaz created this revision.Jul 22 2021, 10:10 AM
mfawaz requested review of this revision.Jul 22 2021, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2021, 10:10 AM

LGTM but I don’t see how this patch is related to the address spaces

LGTM but I don’t see how this patch is related to the address spaces

Thanks Matt. There reason I'm mentioning address spaces is because the case where address spaces are the same is handled by an earlier section of the code, and this patch seems to only be relevant when address spaces are different.

This revision is now accepted and ready to land.Jul 26 2021, 3:35 PM
This revision was landed with ongoing or failed builds.Jul 27 2021, 10:23 AM
This revision was automatically updated to reflect the committed changes.

This patch triggers a (latent) infinite loop problem in instcombine when the memcpy cannot be removed.
It can be seen when replacing the 'i1 false' of the llvm.memcpy in test11 with a 'i1 true', making the memcpy volatile.

This patch triggers a (latent) infinite loop problem in instcombine when the memcpy cannot be removed.
It can be seen when replacing the 'i1 false' of the llvm.memcpy in test11 with a 'i1 true', making the memcpy volatile.

Thank you pointing this out. I have a fix that I am currently testing.

This patch triggers a (latent) infinite loop problem in instcombine when the memcpy cannot be removed.
It can be seen when replacing the 'i1 false' of the llvm.memcpy in test11 with a 'i1 true', making the memcpy volatile.

New differential with the fix here: https://reviews.llvm.org/D106950