Clean up the formatting and trailing whitespace of a routine before

editting it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220146 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2014-10-18 23:19:03 +00:00
parent 440079e53e
commit 01dc911c73

View File

@ -139,9 +139,9 @@ bool llvm::isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB, Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
BasicBlock::iterator &ScanFrom, BasicBlock::iterator &ScanFrom,
unsigned MaxInstsToScan, unsigned MaxInstsToScan,
AliasAnalysis *AA, AliasAnalysis *AA, AAMDNodes *AATags) {
AAMDNodes *AATags) { if (MaxInstsToScan == 0)
if (MaxInstsToScan == 0) MaxInstsToScan = ~0U; MaxInstsToScan = ~0U;
// If we're using alias analysis to disambiguate get the size of *Ptr. // If we're using alias analysis to disambiguate get the size of *Ptr.
uint64_t AccessSize = 0; uint64_t AccessSize = 0;
@ -149,7 +149,7 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
Type *AccessTy = cast<PointerType>(Ptr->getType())->getElementType(); Type *AccessTy = cast<PointerType>(Ptr->getType())->getElementType();
AccessSize = AA->getTypeStoreSize(AccessTy); AccessSize = AA->getTypeStoreSize(AccessTy);
} }
while (ScanFrom != ScanBB->begin()) { while (ScanFrom != ScanBB->begin()) {
// We must ignore debug info directives when counting (otherwise they // We must ignore debug info directives when counting (otherwise they
// would affect codegen). // would affect codegen).
@ -159,29 +159,32 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
// Restore ScanFrom to expected value in case next test succeeds // Restore ScanFrom to expected value in case next test succeeds
ScanFrom++; ScanFrom++;
// Don't scan huge blocks. // Don't scan huge blocks.
if (MaxInstsToScan-- == 0) return nullptr; if (MaxInstsToScan-- == 0)
return nullptr;
--ScanFrom; --ScanFrom;
// If this is a load of Ptr, the loaded value is available. // If this is a load of Ptr, the loaded value is available.
// (This is true even if the load is volatile or atomic, although // (This is true even if the load is volatile or atomic, although
// those cases are unlikely.) // those cases are unlikely.)
if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
if (AreEquivalentAddressValues(LI->getOperand(0), Ptr)) { if (AreEquivalentAddressValues(LI->getOperand(0), Ptr)) {
if (AATags) LI->getAAMetadata(*AATags); if (AATags)
LI->getAAMetadata(*AATags);
return LI; return LI;
} }
if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) { if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
// If this is a store through Ptr, the value is available! // If this is a store through Ptr, the value is available!
// (This is true even if the store is volatile or atomic, although // (This is true even if the store is volatile or atomic, although
// those cases are unlikely.) // those cases are unlikely.)
if (AreEquivalentAddressValues(SI->getOperand(1), Ptr)) { if (AreEquivalentAddressValues(SI->getOperand(1), Ptr)) {
if (AATags) SI->getAAMetadata(*AATags); if (AATags)
SI->getAAMetadata(*AATags);
return SI->getOperand(0); return SI->getOperand(0);
} }
// If Ptr is an alloca and this is a store to a different alloca, ignore // If Ptr is an alloca and this is a store to a different alloca, ignore
// the store. This is a trivial form of alias analysis that is important // the store. This is a trivial form of alias analysis that is important
// for reg2mem'd code. // for reg2mem'd code.
@ -189,18 +192,18 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
(isa<AllocaInst>(SI->getOperand(1)) || (isa<AllocaInst>(SI->getOperand(1)) ||
isa<GlobalVariable>(SI->getOperand(1)))) isa<GlobalVariable>(SI->getOperand(1))))
continue; continue;
// If we have alias analysis and it says the store won't modify the loaded // If we have alias analysis and it says the store won't modify the loaded
// value, ignore the store. // value, ignore the store.
if (AA && if (AA &&
(AA->getModRefInfo(SI, Ptr, AccessSize) & AliasAnalysis::Mod) == 0) (AA->getModRefInfo(SI, Ptr, AccessSize) & AliasAnalysis::Mod) == 0)
continue; continue;
// Otherwise the store that may or may not alias the pointer, bail out. // Otherwise the store that may or may not alias the pointer, bail out.
++ScanFrom; ++ScanFrom;
return nullptr; return nullptr;
} }
// If this is some other instruction that may clobber Ptr, bail out. // If this is some other instruction that may clobber Ptr, bail out.
if (Inst->mayWriteToMemory()) { if (Inst->mayWriteToMemory()) {
// If alias analysis claims that it really won't modify the load, // If alias analysis claims that it really won't modify the load,
@ -208,13 +211,13 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
if (AA && if (AA &&
(AA->getModRefInfo(Inst, Ptr, AccessSize) & AliasAnalysis::Mod) == 0) (AA->getModRefInfo(Inst, Ptr, AccessSize) & AliasAnalysis::Mod) == 0)
continue; continue;
// May modify the pointer, bail out. // May modify the pointer, bail out.
++ScanFrom; ++ScanFrom;
return nullptr; return nullptr;
} }
} }
// Got to the start of the block, we didn't find it, but are done for this // Got to the start of the block, we didn't find it, but are done for this
// block. // block.
return nullptr; return nullptr;