1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Cleanup in preparation for D30703. NFCI

Make the enumerators follow the coding convention and start with OW_...

llvm-svn: 298996
This commit is contained in:
Filipe Cabecinhas 2017-03-29 14:42:27 +00:00
parent 1be3f21c7b
commit c74a7545e9

View File

@ -287,19 +287,14 @@ static uint64_t getPointerSize(const Value *V, const DataLayout &DL,
} }
namespace { namespace {
enum OverwriteResult { enum OverwriteResult { OW_Begin, OW_Complete, OW_End, OW_Unknown };
OverwriteBegin,
OverwriteComplete,
OverwriteEnd,
OverwriteUnknown
};
} }
/// Return 'OverwriteComplete' if a store to the 'Later' location completely /// Return 'OW_Complete' if a store to the 'Later' location completely
/// overwrites a store to the 'Earlier' location, 'OverwriteEnd' if the end of /// overwrites a store to the 'Earlier' location, 'OW_End' if the end of the
/// the 'Earlier' location is completely overwritten by 'Later', /// 'Earlier' location is completely overwritten by 'Later', 'OW_Begin' if the
/// 'OverwriteBegin' if the beginning of the 'Earlier' location is overwritten /// beginning of the 'Earlier' location is overwritten by 'Later', or
/// by 'Later', or 'OverwriteUnknown' if nothing can be determined. /// 'OW_Unknown' if nothing can be determined.
static OverwriteResult isOverwrite(const MemoryLocation &Later, static OverwriteResult isOverwrite(const MemoryLocation &Later,
const MemoryLocation &Earlier, const MemoryLocation &Earlier,
const DataLayout &DL, const DataLayout &DL,
@ -310,7 +305,7 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
// If we don't know the sizes of either access, then we can't do a comparison. // If we don't know the sizes of either access, then we can't do a comparison.
if (Later.Size == MemoryLocation::UnknownSize || if (Later.Size == MemoryLocation::UnknownSize ||
Earlier.Size == MemoryLocation::UnknownSize) Earlier.Size == MemoryLocation::UnknownSize)
return OverwriteUnknown; return OW_Unknown;
const Value *P1 = Earlier.Ptr->stripPointerCasts(); const Value *P1 = Earlier.Ptr->stripPointerCasts();
const Value *P2 = Later.Ptr->stripPointerCasts(); const Value *P2 = Later.Ptr->stripPointerCasts();
@ -320,7 +315,7 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
if (P1 == P2) { if (P1 == P2) {
// Make sure that the Later size is >= the Earlier size. // Make sure that the Later size is >= the Earlier size.
if (Later.Size >= Earlier.Size) if (Later.Size >= Earlier.Size)
return OverwriteComplete; return OW_Complete;
} }
// Check to see if the later store is to the entire object (either a global, // Check to see if the later store is to the entire object (either a global,
@ -332,13 +327,13 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
// If we can't resolve the same pointers to the same object, then we can't // If we can't resolve the same pointers to the same object, then we can't
// analyze them at all. // analyze them at all.
if (UO1 != UO2) if (UO1 != UO2)
return OverwriteUnknown; return OW_Unknown;
// If the "Later" store is to a recognizable object, get its size. // If the "Later" store is to a recognizable object, get its size.
uint64_t ObjectSize = getPointerSize(UO2, DL, TLI); uint64_t ObjectSize = getPointerSize(UO2, DL, TLI);
if (ObjectSize != MemoryLocation::UnknownSize) if (ObjectSize != MemoryLocation::UnknownSize)
if (ObjectSize == Later.Size && ObjectSize >= Earlier.Size) if (ObjectSize == Later.Size && ObjectSize >= Earlier.Size)
return OverwriteComplete; return OW_Complete;
// Okay, we have stores to two completely different pointers. Try to // Okay, we have stores to two completely different pointers. Try to
// decompose the pointer into a "base + constant_offset" form. If the base // decompose the pointer into a "base + constant_offset" form. If the base
@ -350,7 +345,7 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
// If the base pointers still differ, we have two completely different stores. // If the base pointers still differ, we have two completely different stores.
if (BP1 != BP2) if (BP1 != BP2)
return OverwriteUnknown; return OW_Unknown;
// The later store completely overlaps the earlier store if: // The later store completely overlaps the earlier store if:
// //
@ -370,7 +365,7 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
if (EarlierOff >= LaterOff && if (EarlierOff >= LaterOff &&
Later.Size >= Earlier.Size && Later.Size >= Earlier.Size &&
uint64_t(EarlierOff - LaterOff) + Earlier.Size <= Later.Size) uint64_t(EarlierOff - LaterOff) + Earlier.Size <= Later.Size)
return OverwriteComplete; return OW_Complete;
// We may now overlap, although the overlap is not complete. There might also // We may now overlap, although the overlap is not complete. There might also
// be other incomplete overlaps, and together, they might cover the complete // be other incomplete overlaps, and together, they might cover the complete
@ -428,7 +423,7 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
") Composite Later [" << ") Composite Later [" <<
ILI->second << ", " << ILI->first << ")\n"); ILI->second << ", " << ILI->first << ")\n");
++NumCompletePartials; ++NumCompletePartials;
return OverwriteComplete; return OW_Complete;
} }
} }
@ -443,7 +438,7 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
if (!EnablePartialOverwriteTracking && if (!EnablePartialOverwriteTracking &&
(LaterOff > EarlierOff && LaterOff < int64_t(EarlierOff + Earlier.Size) && (LaterOff > EarlierOff && LaterOff < int64_t(EarlierOff + Earlier.Size) &&
int64_t(LaterOff + Later.Size) >= int64_t(EarlierOff + Earlier.Size))) int64_t(LaterOff + Later.Size) >= int64_t(EarlierOff + Earlier.Size)))
return OverwriteEnd; return OW_End;
// Finally, we also need to check if the later store overwrites the beginning // Finally, we also need to check if the later store overwrites the beginning
// of the earlier store. // of the earlier store.
@ -458,11 +453,11 @@ static OverwriteResult isOverwrite(const MemoryLocation &Later,
(LaterOff <= EarlierOff && int64_t(LaterOff + Later.Size) > EarlierOff)) { (LaterOff <= EarlierOff && int64_t(LaterOff + Later.Size) > EarlierOff)) {
assert(int64_t(LaterOff + Later.Size) < assert(int64_t(LaterOff + Later.Size) <
int64_t(EarlierOff + Earlier.Size) && int64_t(EarlierOff + Earlier.Size) &&
"Expect to be handled as OverwriteComplete"); "Expect to be handled as OW_Complete");
return OverwriteBegin; return OW_Begin;
} }
// Otherwise, they don't completely overlap. // Otherwise, they don't completely overlap.
return OverwriteUnknown; return OW_Unknown;
} }
/// If 'Inst' might be a self read (i.e. a noop copy of a /// If 'Inst' might be a self read (i.e. a noop copy of a
@ -909,7 +904,7 @@ static bool tryToShortenBegin(Instruction *EarlierWrite,
if (LaterStart <= EarlierStart && LaterStart + LaterSize > EarlierStart) { if (LaterStart <= EarlierStart && LaterStart + LaterSize > EarlierStart) {
assert(LaterStart + LaterSize < EarlierStart + EarlierSize && assert(LaterStart + LaterSize < EarlierStart + EarlierSize &&
"Should have been handled as OverwriteComplete"); "Should have been handled as OW_Complete");
if (tryToShorten(EarlierWrite, EarlierStart, EarlierSize, LaterStart, if (tryToShorten(EarlierWrite, EarlierStart, EarlierSize, LaterStart,
LaterSize, false)) { LaterSize, false)) {
IntervalMap.erase(OII); IntervalMap.erase(OII);
@ -1105,7 +1100,7 @@ static bool eliminateDeadStores(BasicBlock &BB, AliasAnalysis *AA,
OverwriteResult OR = OverwriteResult OR =
isOverwrite(Loc, DepLoc, DL, *TLI, DepWriteOffset, InstWriteOffset, isOverwrite(Loc, DepLoc, DL, *TLI, DepWriteOffset, InstWriteOffset,
DepWrite, IOL); DepWrite, IOL);
if (OR == OverwriteComplete) { if (OR == OW_Complete) {
DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: " DEBUG(dbgs() << "DSE: Remove Dead Store:\n DEAD: "
<< *DepWrite << "\n KILLER: " << *Inst << '\n'); << *DepWrite << "\n KILLER: " << *Inst << '\n');
@ -1117,15 +1112,15 @@ static bool eliminateDeadStores(BasicBlock &BB, AliasAnalysis *AA,
// We erased DepWrite; start over. // We erased DepWrite; start over.
InstDep = MD->getDependency(Inst); InstDep = MD->getDependency(Inst);
continue; continue;
} else if ((OR == OverwriteEnd && isShortenableAtTheEnd(DepWrite)) || } else if ((OR == OW_End && isShortenableAtTheEnd(DepWrite)) ||
((OR == OverwriteBegin && ((OR == OW_Begin &&
isShortenableAtTheBeginning(DepWrite)))) { isShortenableAtTheBeginning(DepWrite)))) {
assert(!EnablePartialOverwriteTracking && "Do not expect to perform " assert(!EnablePartialOverwriteTracking && "Do not expect to perform "
"when partial-overwrite " "when partial-overwrite "
"tracking is enabled"); "tracking is enabled");
int64_t EarlierSize = DepLoc.Size; int64_t EarlierSize = DepLoc.Size;
int64_t LaterSize = Loc.Size; int64_t LaterSize = Loc.Size;
bool IsOverwriteEnd = (OR == OverwriteEnd); bool IsOverwriteEnd = (OR == OW_End);
MadeChange |= tryToShorten(DepWrite, DepWriteOffset, EarlierSize, MadeChange |= tryToShorten(DepWrite, DepWriteOffset, EarlierSize,
InstWriteOffset, LaterSize, IsOverwriteEnd); InstWriteOffset, LaterSize, IsOverwriteEnd);
} }