[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 26 07:18:47 PDT 2017


Anastasia created this revision.
Herald added a subscriber: yaxunl.

Pipes are now the size of pointers rather than the size of the type that they contain.

Patch by Simon Perretta!


https://reviews.llvm.org/D33597

Files:
  lib/AST/ASTContext.cpp
  test/Index/pipe-size.cl


Index: test/Index/pipe-size.cl
===================================================================
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+__kernel void testPipe( pipe int test )
+{
+    int s = sizeof(test);
+    // X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+    // X86: store i32 8, i32* %s, align 4
+    // SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+    // SPIR: store i32 4, i32* %s, align 4
+    // SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+    // SPIR64: store i32 8, i32* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===================================================================
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-    TypeInfo Info = getTypeInfo(cast<PipeType>(T)->getElementType());
-    Width = Info.Width;
-    Align = Info.Align;
+    Width = Target->getPointerWidth(0);
+    Align = Target->getPointerAlign(0);
   }
 
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33597.100403.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170526/cc943003/attachment.bin>


More information about the cfe-commits mailing list