[PATCH] D55262: [OpenCL] Fix for TBAA information of pointer after addresspacecast

Andrew Savonichev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 12 01:54:40 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL348919: [OpenCL] Fix for TBAA information of pointer after addresspacecast (authored by asavonic, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55262?vs=177012&id=177827#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55262/new/

https://reviews.llvm.org/D55262

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


Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -4269,8 +4269,9 @@
     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());
Index: cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl
===================================================================
--- cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl
+++ cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction2.cl
@@ -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;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55262.177827.patch
Type: text/x-patch
Size: 1567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181212/4e367857/attachment.bin>


More information about the cfe-commits mailing list