Author: asavonic Date: Wed Dec 12 01:51:23 2018 New Revision: 348919 URL: http://llvm.org/viewvc/llvm-project?rev=348919&view=rev Log: [OpenCL] Fix for TBAA information of pointer after addresspacecast
Summary: When addresspacecast is generated resulting pointer should preserve TBAA information from original value. Reviewers: rjmccall, yaxunl, Anastasia Reviewed By: rjmccall Subscribers: asavonic, kosarev, cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D55262 Added: cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=348919&r1=348918&r2=348919&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Dec 12 01:51:23 2018 @@ -4269,8 +4269,9 @@ LValue CodeGenFunction::EmitCastLValue(c QualType DestTy = getContext().getPointerType(E->getType()); llvm::Value *V = getTargetHooks().performAddrSpaceCast( *this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(), - DestTy.getAddressSpace(), ConvertType(DestTy)); - return MakeNaturalAlignPointeeAddrLValue(V, DestTy); + E->getType().getAddressSpace(), ConvertType(DestTy)); + return MakeAddrLValue(Address(V, LV.getAddress().getAlignment()), + E->getType(), LV.getBaseInfo(), LV.getTBAAInfo()); } case CK_ObjCObjectLValueCast: { LValue LV = EmitLValue(E->getSubExpr()); Added: cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl?rev=348919&view=auto ============================================================================== --- cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl (added) +++ cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl Wed Dec 12 01:51:23 2018 @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm -o - | FileCheck %s + +class P { +public: + P(const P &Rhs) = default; + + long A; + long B; +}; + +void foo(__global P *GPtr) { +// CHECK: call void @llvm.memcpy{{.*}}, {{.*}}, i32 16 + P Val = GPtr[0]; +} + +struct __attribute__((packed)) A { int X; }; +int test(__global A *GPtr) { +// CHECK: {{.*}} = load i32, {{.*}}, align 1 + return static_cast<__generic A &>(*GPtr).X; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits