[PATCH] Fix SROA creating invalid bitcasts between address spaces
Matt Arsenault
Matthew.Arsenault at amd.com
Tue Dec 10 15:05:12 PST 2013
Ping
================
Comment at: lib/Transforms/Scalar/SROA.cpp:1432
@@ -1431,3 +1432,3 @@
if (Ptr->getType() != PointerTy)
Ptr = IRB.CreateBitCast(Ptr, PointerTy, "cast");
----------------
Joey Gouly wrote:
> Joey Gouly wrote:
> > This line can also crash! I'll try get a test case.
> Here is the test case, it runs with 'opt -sroa'.
>
> target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64"
> target triple = "armv7-none-linux-gnueabi"
>
> %struct.struct_test_27.0.13 = type { i32, float, i64, i8, [4 x i32] }
>
> ; Function Attrs: nounwind
> define void @copy_struct([5 x i64] %in.coerce) {
> for.end:
> %in = alloca %struct.struct_test_27.0.13, align 8
> %0 = bitcast %struct.struct_test_27.0.13* %in to [5 x i64]*
> store [5 x i64] %in.coerce, [5 x i64]* %0, align 8
> %scevgep9 = getelementptr %struct.struct_test_27.0.13* %in, i32 0, i32 4, i32 0
> %scevgep910 = bitcast i32* %scevgep9 to i8*
> call void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* undef, i8* %scevgep910, i32 16, i32 4, i1 false)
> ret void
> }
>
> ; Function Attrs: nounwind
> declare void @llvm.memcpy.p1i8.p0i8.i32(i8 addrspace(1)* nocapture, i8* nocapture readonly, i32, i32, i1)
>
This works for me. I have a couple more patches that fix SROA address spaces that I missed on the first pass, but they don't seem necessary to also fix this.
http://llvm-reviews.chandlerc.com/D1764
More information about the llvm-commits
mailing list