diff options
author | Dan Gohman <gohman@apple.com> | 2010-05-28 17:44:00 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-05-28 17:44:00 +0000 |
commit | 13ec30b6a1184c590ed93d81764a0314202abeaf (patch) | |
tree | 20b6d157e37e3af96af021e4b02b67230e0d56c5 /lib/Analysis/Lint.cpp | |
parent | 5caeff5c011d9cff5255748b5a0082bca8426554 (diff) | |
download | llvm-13ec30b6a1184c590ed93d81764a0314202abeaf.tar.gz llvm-13ec30b6a1184c590ed93d81764a0314202abeaf.tar.bz2 llvm-13ec30b6a1184c590ed93d81764a0314202abeaf.tar.xz |
Fix lint's memcpy and memmove checks, and its basic block traversal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/Lint.cpp')
-rw-r--r-- | lib/Analysis/Lint.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp index 751c41ce39..91929be346 100644 --- a/lib/Analysis/Lint.cpp +++ b/lib/Analysis/Lint.cpp @@ -248,9 +248,9 @@ void Lint::visitCallSite(CallSite CS) { case Intrinsic::memcpy: { MemCpyInst *MCI = cast<MemCpyInst>(&I); - visitMemoryReference(I, MCI->getSource(), MCI->getAlignment(), 0, - MemRef::Write); visitMemoryReference(I, MCI->getDest(), MCI->getAlignment(), 0, + MemRef::Write); + visitMemoryReference(I, MCI->getSource(), MCI->getAlignment(), 0, MemRef::Read); // Check that the memcpy arguments don't overlap. The AliasAnalysis API @@ -269,9 +269,9 @@ void Lint::visitCallSite(CallSite CS) { } case Intrinsic::memmove: { MemMoveInst *MMI = cast<MemMoveInst>(&I); - visitMemoryReference(I, MMI->getSource(), MMI->getAlignment(), 0, - MemRef::Write); visitMemoryReference(I, MMI->getDest(), MMI->getAlignment(), 0, + MemRef::Write); + visitMemoryReference(I, MMI->getSource(), MMI->getAlignment(), 0, MemRef::Read); break; } @@ -519,11 +519,14 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk, if (LoadInst *L = dyn_cast<LoadInst>(V)) { BasicBlock::iterator BBI = L; BasicBlock *BB = L->getParent(); + SmallPtrSet<BasicBlock *, 4> VisitedBlocks; for (;;) { + if (!VisitedBlocks.insert(BB)) break; if (Value *U = FindAvailableLoadedValue(L->getPointerOperand(), BB, BBI, 6, AA)) return findValueImpl(U, OffsetOk, Visited); - BB = L->getParent()->getUniquePredecessor(); + if (BBI != BB->begin()) break; + BB = BB->getUniquePredecessor(); if (!BB) break; BBI = BB->end(); } |