This is an archive of the discontinued LLVM Phabricator instance.

Look through address space casts in IsConstantOffsetFromGlobal()
Needs ReviewPublic

Authored by arichardson on Dec 12 2017, 8:04 AM.

Details

Summary

I originally needed this change for our fork of clang targeting CHERI which
uses address space 200 extensively. It turns out the only test that fails
after this change is Transforms/ConstProp/loads.ll which already contains
a FIXME for this case.

Event Timeline

arichardson created this revision.Dec 12 2017, 8:04 AM

I'm not sure this is correct because the addrspacecast could include an add of an additional constant offset or some other factor

True, I didn't think of that. For us this will almost always work without adding an additional offset but I am not sure what the correct way to fix this is.

Would it make sense to add a function like canPerformConstantAddrSpaceCast(unsigned FromAS, unsigned ToAS) to DataLayout?

True, I didn't think of that. For us this will almost always work without adding an additional offset but I am not sure what the correct way to fix this is.

Would it make sense to add a function like canPerformConstantAddrSpaceCast(unsigned FromAS, unsigned ToAS) to DataLayout?

I think there correct solution is to allow bitcasts between equivalently sized pointers for no-op casts

arsenm resigned from this revision.Feb 13 2020, 4:54 PM