[PATCH] D32248: CodeGen: Cast alloca to expected address space

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 11 14:01:23 PDT 2017

yaxunl added inline comments.

Comment at: lib/CodeGen/TargetInfo.cpp:7291
+  Address adjustAddrSpaceForAutoVar(Address A, const VarDecl *VD,
+      CodeGen::CodeGenFunction &CGF) const override;
rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > How about, instead of introducing a second method, we just change performAddrSpaceCast to take two AST address spaces and a flag indicating whether the address is known to be non-null?  Does your target have an AST-level address space for the stack?
> > In both AST and LLVM, the destination pointee type of address space cast may be different from the source pointee type (e.g. `addrspacecast i32 addrspace(1)* %a to i8 addrspace(4)*` is valid LLVM instruction), so performAddrSpaceCast needs to know the destination QualType, not just the address space.
> Is there any harm to generating separate cast instructions when this happens?
They should be equivalent but the LLVM IR will be more verbose and take more space, and LLVM passes will take more time since previously they only need to process one instruction but now they need to process two instructions.

The original representation is more concise, why should we change that to emit two instructions instead of one instruction?


More information about the cfe-commits mailing list