diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-04-12 19:03:49 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-04-12 19:03:49 +0000 |
commit | b7b6d0fc664f974512279a55a07bebbeb0c3b129 (patch) | |
tree | b12502d1c91a0b88f20f2ec8efc7b93041713d5d /clang/lib | |
parent | 691ef096d066c690b7890493345e22448c2d5703 (diff) | |
download | bcm5719-llvm-b7b6d0fc664f974512279a55a07bebbeb0c3b129.tar.gz bcm5719-llvm-b7b6d0fc664f974512279a55a07bebbeb0c3b129.zip |
[OpenCL] Handle AddressSpaceConversion when target address space does not change.
In codegen different address spaces may be mapped to the same address
space for a target, e.g. in x86/x86-64 all address spaces are mapped
to 0. Therefore AddressSpaceConversion should be translated by
CreatePointerBitCastOrAddrSpaceCast instead of CreateAddrSpaceCast.
Differential Revision: http://reviews.llvm.org/D18713
llvm-svn: 266107
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 76bfc57cee9..1fd79d0e0ed 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1411,7 +1411,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { } case CK_AddressSpaceConversion: { Value *Src = Visit(const_cast<Expr*>(E)); - return Builder.CreateAddrSpaceCast(Src, ConvertType(DestTy)); + // Since target may map different address spaces in AST to the same address + // space, an address space conversion may end up as a bitcast. + return Builder.CreatePointerBitCastOrAddrSpaceCast(Src, + ConvertType(DestTy)); } case CK_AtomicToNonAtomic: case CK_NonAtomicToAtomic: |