[PATCH] D45900: CodeGen: Fix invalid bitcast for lifetime.start/end
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 9 09:58:28 PDT 2018
yaxunl added a comment.
In https://reviews.llvm.org/D45900#1083377, @rjmccall wrote:
> Oh, I see, it's not that the lifetime intrinsics don't handle pointers in the alloca address space, it's that we might have already promoted them into `DefaultAS`.
>
> Do the LLVM uses of lifetime intrinsics actually look through these address space casts? I'm wondering if we might need to change how we emit the intrinsics so that they're emitted directly on (bitcasts of) the underlying allocas.
Some passes do not look through address space casts. Although there is InferAddressSpace pass which can eliminate the redundant address space casts, still it is desirable not to emit redundant address space in Clang.
To avoid increasing complexity of alloca emitting API, I think we need a way to track the original alloca and the alloca casted to default address space. I can think of two ways:
1. add OriginalPointer member to Address, which is the originally emitted LLVM value for the variable. Whenever we pass the address of a variable we also pass the original LLVM value.
2. add a map to CodeGenFunction to map the casted alloca to the real alloca.
Any suggestion? Thanks.
https://reviews.llvm.org/D45900
More information about the cfe-commits
mailing list