Enhance the memdep interface so that users can tell the difference between a dependency which cannot be calculated and a path reaching the entry point of the function. This patch introduces isNonFuncLocal, which replaces isUnknown in some cases.

Patch by Xiaoyi Guo.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141896 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman
2011-10-13 22:14:57 +00:00
parent 48ba0e45ed
commit b414142036
6 changed files with 107 additions and 61 deletions
@@ -441,7 +441,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
// Ignore any store where we can't find a local dependence.
// FIXME: cross-block DSE would be fun. :)
if (InstDep.isNonLocal() || InstDep.isUnknown())
if (!InstDep.isDef() && !InstDep.isClobber())
continue;
// If we're storing the same value back to a pointer that we just
@@ -477,7 +477,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
if (Loc.Ptr == 0)
continue;
while (!InstDep.isNonLocal() && !InstDep.isUnknown()) {
while (InstDep.isDef() || InstDep.isClobber()) {
// Get the memory clobbered by the instruction we depend on. MemDep will
// skip any instructions that 'Loc' clearly doesn't interact with. If we
// end up depending on a may- or must-aliased load, then we can't optimize
@@ -545,7 +545,7 @@ bool DSE::HandleFree(CallInst *F) {
MemDepResult Dep = MD->getDependency(F);
while (!Dep.isNonLocal() && !Dep.isUnknown()) {
while (Dep.isDef() || Dep.isClobber()) {
Instruction *Dependency = Dep.getInst();
if (!hasMemoryWrite(Dependency) || !isRemovable(Dependency))
return MadeChange;