llvm.org GIT mirror llvm / f478951
fix PR3217: fully cached queries need to be verified against the visited set before they are used. If used, their blocks need to be added to the visited set so that subsequent queries don't use conflicting pointer values in the cache result blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61080 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
2 changed file(s) with 49 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
600600 // If we have valid cached information for exactly the block we are
601601 // investigating, just return it with no recomputation.
602602 if (CacheInfo->first == BBSkipFirstBlockPair(StartBB, SkipFirstBlock)) {
603 // We have a fully cached result for this query then we can just return the
604 // cached results and populate the visited set. However, we have to verify
605 // that we don't already have conflicting results for these blocks. Check
606 // to ensure that if a block in the results set is in the visited set that
607 // it was for the same pointer query.
608 if (!Visited.empty()) {
609 for (NonLocalDepInfo::iterator I = Cache->begin(), E = Cache->end();
610 I != E; ++I) {
611 DenseMap::iterator VI = Visited.find(I->first);
612 if (VI == Visited.end() || VI->second == Pointer) continue;
613
614 // We have a pointer mismatch in a block. Just return clobber, saying
615 // that something was clobbered in this result. We could also do a
616 // non-fully cached query, but there is little point in doing this.
617 return true;
618 }
619 }
620
603621 for (NonLocalDepInfo::iterator I = Cache->begin(), E = Cache->end();
604 I != E; ++I)
622 I != E; ++I) {
623 Visited.insert(std::make_pair(I->first, Pointer));
605624 if (!I->second.isNonLocal())
606625 Result.push_back(*I);
626 }
607627 ++NumCacheCompleteNonLocalPtr;
608628 return false;
609629 }
0 ; RUN: llvm-as < %s | opt -gvn | llvm-dis
1 ; Cached results must be added to and verified against the visited sets.
2 ; PR3217
3
4 define fastcc void @gen_field_die(i32* %decl) nounwind {
5 entry:
6 br i1 false, label %bb203, label %bb202
7
8 bb202: ; preds = %entry
9 unreachable
10
11 bb203: ; preds = %entry
12 %tmp = getelementptr i32* %decl, i32 1 ; [#uses=1]
13 %tmp1 = load i32* %tmp, align 4 ; [#uses=0]
14 br i1 false, label %bb207, label %bb204
15
16 bb204: ; preds = %bb203
17 %tmp2 = getelementptr i32* %decl, i32 1 ; [#uses=1]
18 br label %bb208
19
20 bb207: ; preds = %bb203
21 br label %bb208
22
23 bb208: ; preds = %bb207, %bb204
24 %iftmp.1374.0.in = phi i32* [ null, %bb207 ], [ %tmp2, %bb204 ] ; [#uses=1]
25 %iftmp.1374.0 = load i32* %iftmp.1374.0.in ; [#uses=0]
26 unreachable
27 }