[PATCH] D36118: Fix creating bitcasts with wrong address space

Matt Arsenault via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 31 15:22:46 PDT 2017


arsenm created this revision.
Herald added subscribers: Anastasia, tpr, wdng.

In a future commit AMDGPU will start passing
aggregates directly to more functions, triggering
asserts in test/CodeGenOpenCL/addr-space-struct-arg.cl


https://reviews.llvm.org/D36118

Files:
  lib/CodeGen/CGCall.cpp


Index: lib/CodeGen/CGCall.cpp
===================================================================
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1223,7 +1223,8 @@
     //
     // FIXME: Assert that we aren't truncating non-padding bits when have access
     // to that information.
-    Src = CGF.Builder.CreateBitCast(Src, llvm::PointerType::getUnqual(Ty));
+    Src = CGF.Builder.CreateBitCast(Src,
+                                    Ty->getPointerTo(Src.getAddressSpace()));
     return CGF.Builder.CreateLoad(Src);
   }
 
@@ -3946,7 +3947,8 @@
           Builder.CreateMemCpy(TempAlloca, Src, SrcSize);
           Src = TempAlloca;
         } else {
-          Src = Builder.CreateBitCast(Src, llvm::PointerType::getUnqual(STy));
+          Src = Builder.CreateBitCast(Src,
+                                      STy->getPointerTo(Src.getAddressSpace()));
         }
 
         auto SrcLayout = CGM.getDataLayout().getStructLayout(STy);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36118.109016.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170731/86147981/attachment-0001.bin>


More information about the cfe-commits mailing list