summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2017-09-27 14:37:00 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2017-09-27 14:37:00 +0000
commit0a72ed40d3ce5bbd8c4a1228527f2b22b48379d0 (patch)
treed997f40226b057a979c2850ad039ffee7d648c74 /clang/lib
parent965c7e9c6e176d8241e3cbf0e003c20d8fa7c189 (diff)
downloadbcm5719-llvm-0a72ed40d3ce5bbd8c4a1228527f2b22b48379d0.tar.gz
bcm5719-llvm-0a72ed40d3ce5bbd8c4a1228527f2b22b48379d0.zip
[OpenCL] Handle address space conversion while setting type alignment.
Added missing addrspacecast case in alignment computation logic of pointer type emission in IR generation. Differential Revision: https://reviews.llvm.org/D37804 llvm-svn: 314304
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGBuilder.h7
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp7
2 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 42f9a428bb3..61fe4aac3af 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -145,6 +145,13 @@ public:
Addr.getAlignment());
}
+ using CGBuilderBaseTy::CreateAddrSpaceCast;
+ Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
+ const llvm::Twine &Name = "") {
+ return Address(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
+ Addr.getAlignment());
+ }
+
/// Cast the element type of the given address to a different type,
/// preserving information like the alignment and address space.
Address CreateElementBitCast(Address Addr, llvm::Type *Ty,
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index cf3dc49ef2a..4659d1b5208 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -925,6 +925,7 @@ Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E,
// Non-converting casts (but not C's implicit conversion from void*).
case CK_BitCast:
case CK_NoOp:
+ case CK_AddressSpaceConversion:
if (auto PtrTy = CE->getSubExpr()->getType()->getAs<PointerType>()) {
if (PtrTy->getPointeeType()->isVoidType())
break;
@@ -953,8 +954,10 @@ Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E,
CodeGenFunction::CFITCK_UnrelatedCast,
CE->getLocStart());
}
-
- return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+ return CE->getCastKind() != CK_AddressSpaceConversion
+ ? Builder.CreateBitCast(Addr, ConvertType(E->getType()))
+ : Builder.CreateAddrSpaceCast(Addr,
+ ConvertType(E->getType()));
}
break;
OpenPOWER on IntegriCloud