forked from OSchip/llvm-project
[MemCpyOpt] Don't hoist store that's not guaranteed to execute
MemCpyOpt can hoist stores while load+store pairs into memcpy. This hoisting can currently result in stores being executed that weren't guaranteed to execute in the original problem. Differential Revision: https://reviews.llvm.org/D89154
This commit is contained in:
parent
2b96dcebfa
commit
5e855f1e80
|
@ -491,6 +491,11 @@ bool MemCpyOptPass::moveUp(StoreInst *SI, Instruction *P, const LoadInst *LI) {
|
|||
for (auto I = --SI->getIterator(), E = P->getIterator(); I != E; --I) {
|
||||
auto *C = &*I;
|
||||
|
||||
// Make sure hoisting does not perform a store that was not guaranteed to
|
||||
// happen.
|
||||
if (!isGuaranteedToTransferExecutionToSuccessor(C))
|
||||
return false;
|
||||
|
||||
bool MayAlias = isModOrRefSet(AA->getModRefInfo(C, None));
|
||||
|
||||
bool NeedLift = false;
|
||||
|
|
|
@ -147,12 +147,11 @@ define void @noaliasaddrproducer(%S* %src, %S* noalias %dst, i32* noalias %dstid
|
|||
|
||||
define void @throwing_call(%S* noalias %src, %S* %dst) {
|
||||
; CHECK-LABEL: @throwing_call(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = bitcast %S* [[SRC:%.*]] to i8*
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = bitcast %S* [[DST:%.*]] to i8*
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = bitcast %S* [[SRC]] to i8*
|
||||
; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[TMP2]], i8* align 8 [[TMP3]], i64 16, i1 false)
|
||||
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 8 [[TMP1]], i8 0, i64 16, i1 false)
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = load [[S:%.*]], %S* [[SRC:%.*]], align 8
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = bitcast %S* [[SRC]] to i8*
|
||||
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 8 [[TMP2]], i8 0, i64 16, i1 false)
|
||||
; CHECK-NEXT: call void @call() [[ATTR2:#.*]]
|
||||
; CHECK-NEXT: store [[S]] [[TMP1]], %S* [[DST:%.*]], align 8
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
%1 = load %S, %S* %src
|
||||
|
|
Loading…
Reference in New Issue