[PATCH] D46643: CodeGen: Emit string literal in constant address space
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 10 08:41:24 PDT 2018
rjmccall added inline comments.
================
Comment at: lib/CodeGen/CGDecl.cpp:1375
+ Loc = Address(EmitCastToVoidPtrInAllocaAddrSpace(Loc.getPointer()),
+ Loc.getAlignment());
----------------
yaxunl wrote:
> rjmccall wrote:
> > I don't understand why a patch about string literals is changing auto variable emission.
> It is a bug about alloca revealed by the lit test
>
>
> ```
> char l_array[] = "l_array";
>
> ```
> Loc contains the alloca casted to default address space, therefore it needs to be casted back to alloca address space here, otherwise CreateBitCast returns invalid bitcast. Unlike lifetime.start, memcpy does not require alloca address space, so an alternative fix is to let BP take address space of Loc.
Yeah, I think using the address space of Loc is more appropriate.
https://reviews.llvm.org/D46643
More information about the cfe-commits
mailing list