From e1468322eb41cf2b816860a9a89e6ed26f977f49 Mon Sep 17 00:00:00 2001 From: David Tweed Date: Wed, 11 Dec 2013 13:39:46 +0000 Subject: Add front-end infrastructure now address space casts are in LLVM IR. With the introduction of explicit address space casts into LLVM, there's a need to provide a new cast kind the front-end can create for C/OpenCL/CUDA and code to produce address space casts from those kinds when appropriate. Patch by Michele Scandale! llvm-svn: 197036 --- clang/lib/CodeGen/CGExprConstant.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CGExprConstant.cpp') diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index f4d6861c8b8..ad3e1fcbef0 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -633,6 +633,9 @@ public: return llvm::ConstantStruct::get(STy, Elts); } + case CK_AddressSpaceConversion: + return llvm::ConstantExpr::getAddrSpaceCast(C, destType); + case CK_LValueToRValue: case CK_AtomicToNonAtomic: case CK_NonAtomicToAtomic: @@ -1062,13 +1065,13 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value, if (!Offset->isNullValue()) { llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Int8PtrTy); Casted = llvm::ConstantExpr::getGetElementPtr(Casted, Offset); - C = llvm::ConstantExpr::getBitCast(Casted, C->getType()); + C = llvm::ConstantExpr::getPointerCast(Casted, C->getType()); } // Convert to the appropriate type; this could be an lvalue for // an integer. if (isa(DestTy)) - return llvm::ConstantExpr::getBitCast(C, DestTy); + return llvm::ConstantExpr::getPointerCast(C, DestTy); return llvm::ConstantExpr::getPtrToInt(C, DestTy); } else { -- cgit v1.2.3