llvm.org GIT mirror llvm / 3668de5
Merging r167912: into the 3.2 release branch. Handle DAG CSE adding new uses during ReplaceAllUsesWith. Fixes PR14333. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168596 91177308-0d34-0410-b5e6-96231b3b80d8 Pawel Wodnicki 6 years ago
2 changed file(s) with 24 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
77277727 if (StoreNodes[i].MemNode == EarliestOp)
77287728 continue;
77297729 StoreSDNode *St = cast(StoreNodes[i].MemNode);
7730 DAG.ReplaceAllUsesOfValueWith(SDValue(St, 0), St->getChain());
7730 // ReplaceAllUsesWith will replace all uses that existed when it was
7731 // called, but graph optimizations may cause new ones to appear. For
7732 // example, the case in pr14333 looks like
7733 //
7734 // St's chain -> St -> another store -> X
7735 //
7736 // And the only difference from St to the other store is the chain.
7737 // When we change it's chain to be St's chain they become identical,
7738 // get CSEed and the net result is that X is now a use of St.
7739 // Since we know that St is redundant, just iterate.
7740 while (!St->use_empty())
7741 DAG.ReplaceAllUsesWith(SDValue(St, 0), St->getChain());
77317742 removeFromWorkList(St);
77327743 DAG.DeleteNode(St);
77337744 }
0 ; RUN: llc -mtriple=x86_64-unknown-unknown < %s
1 %foo = type { i64, i64 }
2 define void @bar(%foo* %zed) {
3 %tmp = getelementptr inbounds %foo* %zed, i64 0, i32 0
4 store i64 0, i64* %tmp, align 8
5 %tmp2 = getelementptr inbounds %foo* %zed, i64 0, i32 1
6 store i64 0, i64* %tmp2, align 8
7 %tmp3 = bitcast %foo* %zed to i8*
8 call void @llvm.memset.p0i8.i64(i8* %tmp3, i8 0, i64 16, i32 8, i1 false)
9 ret void
10 }
11 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind