romanovvlad created this revision.
romanovvlad added reviewers: rjmccall, yaxunl, Anastasia.
Herald added a subscriber: kosarev.

When addresspacecast is generated resulting pointer should preserve TBAA 
information from original value.


Repository:
  rC Clang

https://reviews.llvm.org/D55262

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenOpenCLCXX/address-space-deduction2.cl


Index: test/CodeGenOpenCLCXX/address-space-deduction2.cl
===================================================================
--- test/CodeGenOpenCLCXX/address-space-deduction2.cl
+++ test/CodeGenOpenCLCXX/address-space-deduction2.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm 
-o - | FileCheck %s
+
+// CHECK: call void @llvm.memcpy{{.*}}, {{.*}}, i32 16
+
+class P {
+public:
+  P(const P &Rhs) = default;
+
+  long a;
+  long b;
+};
+
+__kernel void foo(__global P* GPtr) {
+  P Val = GPtr[0];
+}
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -4270,7 +4270,9 @@
     llvm::Value *V = getTargetHooks().performAddrSpaceCast(
         *this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(),
         DestTy.getAddressSpace(), ConvertType(DestTy));
-    return MakeNaturalAlignPointeeAddrLValue(V, DestTy);
+    return MakeAddrLValue(Address(V, LV.getAddress().getAlignment()),
+                          E->getType(), LV.getBaseInfo(),
+                          LV.getTBAAInfo());
   }
   case CK_ObjCObjectLValueCast: {
     LValue LV = EmitLValue(E->getSubExpr());


Index: test/CodeGenOpenCLCXX/address-space-deduction2.cl
===================================================================
--- test/CodeGenOpenCLCXX/address-space-deduction2.cl
+++ test/CodeGenOpenCLCXX/address-space-deduction2.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm -o - | FileCheck %s
+
+// CHECK: call void @llvm.memcpy{{.*}}, {{.*}}, i32 16
+
+class P {
+public:
+  P(const P &Rhs) = default;
+
+  long a;
+  long b;
+};
+
+__kernel void foo(__global P* GPtr) {
+  P Val = GPtr[0];
+}
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -4270,7 +4270,9 @@
     llvm::Value *V = getTargetHooks().performAddrSpaceCast(
         *this, LV.getPointer(), E->getSubExpr()->getType().getAddressSpace(),
         DestTy.getAddressSpace(), ConvertType(DestTy));
-    return MakeNaturalAlignPointeeAddrLValue(V, DestTy);
+    return MakeAddrLValue(Address(V, LV.getAddress().getAlignment()),
+                          E->getType(), LV.getBaseInfo(),
+                          LV.getTBAAInfo());
   }
   case CK_ObjCObjectLValueCast: {
     LValue LV = EmitLValue(E->getSubExpr());
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to