[llvm-dev] [RFC] : LLVM IR should allow bitcast between address spaces with the same size

Renato Golin via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 30 01:51:32 PST 2021


On Mon, 29 Nov 2021 at 18:15, Matt Arsenault <arsenm2 at gmail.com> wrote:

> This is true, but this isn’t directly related to this change. If the
> target does not have no-op conversions between a given pair of address
> spaces, the original code was broken to begin with. This change does not
> allow introducing new illegal address space conversions that were not
> already present in the original program. It’s garbage in, garbage out. If
> the target can’t really reinterpret these pointers, it would be UB on
> access.
>

Ah, I see.

So IIUC, adding the casts in the first place would have to know about
target address spaces, but this specific change only allows eliding the
inttoptr cast in the specific case where the address spaces have the same
data layout?

Assuming the initial cast was legal to begin with, this looks sensible to
me.

I was worried this would allow (encourage?) front-ends and other passes to
add an address space cast where none (could have) existed in the first
place.

Sorry for the noise.

--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211130/f054c628/attachment.html>


More information about the llvm-dev mailing list