GBE: Fix a TBAA issue against llvm5.0.

Submitted by Song, Ruiling on Oct. 18, 2017, 6:57 a.m.

Details

Message ID 1508309834-17561-1-git-send-email-ruiling.song@intel.com
State New
Headers show
Series "GBE: Fix a TBAA issue against llvm5.0." ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Song, Ruiling Oct. 18, 2017, 6:57 a.m.
From: Yang Rong <rong.r.yang@intel.com>

Casting from pointer of char to pointer of int breaks llvm
TypeBasedAliasAnalysis. So we use may_alias attribute to explicitly
tell the TBAA that it may alias other data type memory access.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
---
 backend/src/libocl/src/ocl_memcpy.cl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/backend/src/libocl/src/ocl_memcpy.cl b/backend/src/libocl/src/ocl_memcpy.cl
index 131574d..8c0409a 100644
--- a/backend/src/libocl/src/ocl_memcpy.cl
+++ b/backend/src/libocl/src/ocl_memcpy.cl
@@ -16,12 +16,13 @@ 
  *
  */
 #include "ocl_memcpy.h"
+typedef int __attribute__((may_alias)) AI;
 
 #define DECL_TWO_SPACE_MEMCOPY_FN(NAME, DST_SPACE, SRC_SPACE) \
 void __gen_memcpy_ ##NAME## _align (DST_SPACE uchar* dst, SRC_SPACE uchar* src, size_t size) { \
   size_t index = 0; \
   while((index + 4) <= size) { \
-    *((DST_SPACE uint *)(dst + index)) = *((SRC_SPACE uint *)(src + index)); \
+    *((DST_SPACE AI *)(dst + index)) = *((SRC_SPACE AI *)(src + index)); \
     index += 4; \
   } \
   while(index < size) { \