[llvm-commits] [llvm] r164641 - in /llvm/trunk: lib/Transforms/Scalar/SROA.cpp test/Transforms/SROA/basictest.ll
Nick Lewycky
nicholas at mxc.ca
Tue Sep 25 15:46:22 PDT 2012
Author: nicholas
Date: Tue Sep 25 17:46:21 2012
New Revision: 164641
URL: http://llvm.org/viewvc/llvm-project?rev=164641&view=rev
Log:
Don't drop the alignment on a memcpy intrinsic when producing a store. This is
only a missed optimization opportunity if the store is over-aligned, but a
miscompile if the store's new type has a higher natural alignment than the
memcpy did. Fixes PR13920!
Modified:
llvm/trunk/lib/Transforms/Scalar/SROA.cpp
llvm/trunk/test/Transforms/SROA/basictest.ll
Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=164641&r1=164640&r2=164641&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Tue Sep 25 17:46:21 2012
@@ -2272,8 +2272,9 @@
getName(".insert"));
}
- Value *Store = IRB.CreateStore(Src, DstPtr, II.isVolatile());
- (void)Store;
+ StoreInst *Store = cast<StoreInst>(IRB.CreateStore(Src, DstPtr,
+ II.isVolatile()));
+ Store->setAlignment(II.getAlignment());
DEBUG(dbgs() << " to: " << *Store << "\n");
return !II.isVolatile();
}
Modified: llvm/trunk/test/Transforms/SROA/basictest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SROA/basictest.ll?rev=164641&r1=164640&r2=164641&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SROA/basictest.ll (original)
+++ llvm/trunk/test/Transforms/SROA/basictest.ll Tue Sep 25 17:46:21 2012
@@ -863,6 +863,7 @@
; CHECK-NOT: alloca
; CHECK: ret void
; PR13916
+
entry:
%A = alloca %test22.struct
br i1 undef, label %if.then, label %if.end
@@ -877,3 +878,18 @@
%tmp2 = load %test22.struct* %A
ret void
}
+
+define void @test23(<2 x i64> %a, i16* %b) {
+; CHECK: @test23
+; CHECK: store {{.*}}, align 2
+; CHECK: ret void
+; PR13920
+
+entry:
+ %a.addr = alloca <2 x i64>, align 16
+ store <2 x i64> %a, <2 x i64>* %a.addr, align 16
+ %0 = bitcast i16* %b to i8*
+ %1 = bitcast <2 x i64>* %a.addr to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 16, i32 2, i1 false)
+ ret void
+}
More information about the llvm-commits
mailing list