llvm.org GIT mirror llvm / fe4360e
[DSE] Fix bug in partial overwrite tracking Summary: Found cases where DSE incorrectly add partially-overwritten intervals. Please see the test case for details. Reviewers: mcrosier, eeckstein, hfinkel Subscribers: mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D21859 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274237 91177308-0d34-0410-b5e6-96231b3b80d8 Jun Bum Lim 3 years ago
2 changed file(s) with 53 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
384384 // Find any intervals ending at, or after, LaterIntStart which start
385385 // before LaterIntEnd.
386386 auto ILI = IM.lower_bound(LaterIntStart);
387 if (ILI != IM.end() && ILI->second < LaterIntEnd) {
388 // This existing interval ends in the middle of
389 // [LaterIntStart, LaterIntEnd), erase it adjusting our start.
387 if (ILI != IM.end() && ILI->second <= LaterIntEnd) {
388 // This existing interval is overlapped with the current store somewhere
389 // in [LaterIntStart, LaterIntEnd]. Merge them by erasing the existing
390 // intervals and adjusting our start and end.
390391 LaterIntStart = std::min(LaterIntStart, ILI->second);
391392 LaterIntEnd = std::max(LaterIntEnd, ILI->first);
392393 ILI = IM.erase(ILI);
393394
394 while (ILI != IM.end() && ILI->first <= LaterIntEnd)
395 // Continue erasing and adjusting our end in case other previous
396 // intervals are also overlapped with the current store.
397 //
398 // |--- ealier 1 ---| |--- ealier 2 ---|
399 // |------- later---------|
400 //
401 while (ILI != IM.end() && ILI->second <= LaterIntEnd) {
402 assert(ILI->second > LaterIntStart && "Unexpected interval");
403 LaterIntEnd = std::max(LaterIntEnd, ILI->first);
395404 ILI = IM.erase(ILI);
396
397 if (ILI != IM.end() && ILI->second < LaterIntEnd)
398 LaterIntEnd = std::max(LaterIntEnd, ILI->first);
405 }
399406 }
400407
401408 IM[LaterIntEnd] = LaterIntStart;
197197 ret i8 0
198198 }
199199
200 define signext i8 @test6(i32 *%ptr) {
201 entry:
202 ; CHECK-LABEL: @test6
203
204 store i32 0, i32* %ptr
205
206 %bptr = bitcast i32* %ptr to i16*
207 %bptr1 = getelementptr inbounds i16, i16* %bptr, i64 0
208 %bptr2 = getelementptr inbounds i16, i16* %bptr, i64 1
209
210 store i16 1456, i16* %bptr2, align 1
211 store i16 65535, i16* %bptr1, align 1
212
213 ; CHECK-NOT: store i32 0, i32* %ptr
214
215 ret i8 0
216 }
217
218 define signext i8 @test7(i64 *%ptr) {
219 entry:
220 ; CHECK-LABEL: @test7
221
222 store i64 0, i64* %ptr
223
224 %bptr = bitcast i64* %ptr to i16*
225 %bptr1 = getelementptr inbounds i16, i16* %bptr, i64 0
226 %bptr2 = getelementptr inbounds i16, i16* %bptr, i64 1
227 %bptr3 = getelementptr inbounds i16, i16* %bptr, i64 2
228 %bptr4 = getelementptr inbounds i16, i16* %bptr, i64 3
229
230 store i16 1346, i16* %bptr1, align 1
231 store i16 1756, i16* %bptr3, align 1
232 store i16 1456, i16* %bptr2, align 1
233 store i16 5656, i16* %bptr4, align 1
234
235 ; CHECK-NOT: store i64 0, i64* %ptr
236
237 ret i8 0
238 }