[PATCH] D19697: SROA assertion: creating bitcast between ptr types with different addr spaces
Jack Liu via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 08:55:07 PDT 2016
liu12295 removed rL LLVM as the repository for this revision.
liu12295 updated this revision to Diff 55608.
liu12295 added a comment.
Add FileCheck, so that we can see the problem even with release build. The original test will trigger assertion only on debug build.
http://reviews.llvm.org/D19697
Files:
lib/Transforms/Scalar/SROA.cpp
test/Transforms/SROA/pr27557.ll
Index: test/Transforms/SROA/pr27557.ll
===================================================================
--- test/Transforms/SROA/pr27557.ll
+++ test/Transforms/SROA/pr27557.ll
@@ -0,0 +1,22 @@
+; RUN: opt < %s -sroa -S | FileCheck %s
+
+; ModuleID = '<origin>'
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+
+%union.anon = type { i32 addrspace(1)* }
+
+ at g = common addrspace(1) global i32 0, align 4
+ at l = common addrspace(3) global i32 0, align 4
+
+; CHECK: %[[CAST:.*]] = bitcast i32 addrspace(1)** {{.*}} to i32 addrspace(3)**
+; CHECK: store i32 addrspace(3)* @l, i32 addrspace(3)** %[[CAST]]
+
+; Function Attrs: nounwind uwtable
+define void @testKernel() #0 {
+ %1 = alloca %union.anon, align 8
+ %2 = bitcast %union.anon* %1 to i32 addrspace(1)**
+ store i32 addrspace(1)* @g, i32 addrspace(1)** %2, align 8
+ %3 = bitcast %union.anon* %1 to i32 addrspace(3)**
+ store i32 addrspace(3)* @l, i32 addrspace(3)** %3, align 8
+ ret void
+}
Index: lib/Transforms/Scalar/SROA.cpp
===================================================================
--- lib/Transforms/Scalar/SROA.cpp
+++ lib/Transforms/Scalar/SROA.cpp
@@ -1635,8 +1635,10 @@
OldTy = OldTy->getScalarType();
NewTy = NewTy->getScalarType();
if (NewTy->isPointerTy() || OldTy->isPointerTy()) {
- if (NewTy->isPointerTy() && OldTy->isPointerTy())
- return true;
+ if (NewTy->isPointerTy() && OldTy->isPointerTy()) {
+ return cast<PointerType>(NewTy)->getPointerAddressSpace() ==
+ cast<PointerType>(OldTy)->getPointerAddressSpace();
+ }
if (NewTy->isIntegerTy() || OldTy->isIntegerTy())
return true;
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19697.55608.patch
Type: text/x-patch
Size: 1656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160429/f69f36af/attachment-0001.bin>
More information about the llvm-commits
mailing list