diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-11-30 00:28:45 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-11-30 00:28:45 +0000 | 
| commit | 9a146372b526f659991ede75f10f07c30209234b (patch) | |
| tree | 9851ab0a6fc034f241623cc416998b3d66acb01e /llvm/lib/Transforms | |
| parent | 348b5897f94a856044cab9a241e889013a8611cc (diff) | |
| download | bcm5719-llvm-9a146372b526f659991ede75f10f07c30209234b.tar.gz bcm5719-llvm-9a146372b526f659991ede75f10f07c30209234b.zip | |
Teach basicaa that memset's modref set is at worst "mod" and never
contains "ref".
Enhance DSE to use a modref query instead of a store-specific hack
to generalize the "ignore may-alias stores" optimization to handle
memset and memcpy.
llvm-svn: 120368
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 19 | 
1 files changed, 12 insertions, 7 deletions
| diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index dd66416e7fe..d9f5bc51cbc 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -191,6 +191,7 @@ static bool isStoreAtLeastAsWideAs(Instruction *I1, Instruction *I2,           I1Size >= I2Size;  } +  bool DSE::runOnBasicBlock(BasicBlock &BB) {    MemoryDependenceAnalysis &MD = getAnalysis<MemoryDependenceAnalysis>();    TD = getAnalysisIfAvailable<TargetData>(); @@ -239,7 +240,7 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {          }        }      } -      +      if (!InstDep.isDef()) {        // If this is a may-aliased store that is clobbering the store value, we        // can keep searching past it for another must-aliased pointer that stores @@ -250,12 +251,16 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {        // we can remove the first store to P even though we don't know if P and Q        // alias.        if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) { -        AliasAnalysis::Location Loc = -          getAnalysis<AliasAnalysis>().getLocation(SI); -        while (InstDep.isClobber() && isa<StoreInst>(InstDep.getInst()) && -               InstDep.getInst() != &BB.front()) -          InstDep = MD.getPointerDependencyFrom(Loc, false, InstDep.getInst(), -                                                &BB); +        AliasAnalysis &AA = getAnalysis<AliasAnalysis>(); +        AliasAnalysis::Location Loc = AA.getLocation(SI); +        while (InstDep.isClobber() && InstDep.getInst() != &BB.front()) { +          // Can't look past this instruction if it might read 'Loc'. +          if (AA.getModRefInfo(InstDep.getInst(), Loc) & AliasAnalysis::Ref) +            break; +           +          InstDep = MD.getPointerDependencyFrom(Loc, false, +                                                InstDep.getInst(), &BB); +        }        }      } | 

