[PATCH] D18586: Allow DeadStoreElimination to track combinations of partial later wrties
Jake VanAdrighem via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 30 20:31:59 PDT 2016
JakeVanAdrighem added a subscriber: JakeVanAdrighem.
JakeVanAdrighem added a comment.
This is great! This actually fixes a problem case I ran into some months ago in the wild, where a `memset` wasn't being wiped away despite being fully overwritten by the stores following it. Example shown below:
%struct.foostruct = type {
i32 (i8*, i8**, i32, i8, i8*)*,
i32 (i8*, i8**, i32, i8, i8*)*,
i32 (i8*, i8**, i32, i8, i8*)*,
i32 (i8*, i8**, i32, i8, i8*)*,
void (i8*, i32, i32)*
}
declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1)
declare void @goFunc(%struct.foostruct*)
define void @func() {
%bang = alloca %struct.foostruct, align 8
%1 = bitcast %struct.foostruct* %bang to i8*
call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 40, i32 8, i1 false) <------ This is now removed
%2 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 0
store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %2, align 8
%3 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 1
store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %3, align 8
%4 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 2
store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %4, align 8
%5 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 3
store i32 (i8*, i8**, i32, i8, i8*)* @fa, i32 (i8*, i8**, i32, i8, i8*)** %5, align 8
%6 = getelementptr inbounds %struct.foostruct, %struct.foostruct* %bang, i64 0, i32 4
store void (i8*, i32, i32)* null, void (i8*, i32, i32)** %6, align 8
call void @goFunc(%struct.foostruct* %bang)
ret void
}
http://reviews.llvm.org/D18586
More information about the llvm-commits
mailing list