Skip to content

Commit

Permalink
[DSE] Return std::optional from getPointerSize() (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Oct 23, 2023
1 parent e3adc6a commit d95d1c3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,17 @@ static bool isShortenableAtTheBeginning(Instruction *I) {
return isa<AnyMemSetInst>(I);
}

static uint64_t getPointerSize(const Value *V, const DataLayout &DL,
const TargetLibraryInfo &TLI,
const Function *F) {
static std::optional<uint64_t> getPointerSize(const Value *V,
const DataLayout &DL,
const TargetLibraryInfo &TLI,
const Function *F) {
uint64_t Size;
ObjectSizeOpts Opts;
Opts.NullIsUnknownSize = NullPointerIsDefined(F);

if (getObjectSize(V, Size, DL, &TLI, Opts))
return Size;
return MemoryLocation::UnknownSize;
return std::nullopt;
}

namespace {
Expand Down Expand Up @@ -951,9 +952,9 @@ struct DSEState {
// case the size/offset of the dead store does not matter.
if (DeadUndObj == KillingUndObj && KillingLocSize.isPrecise() &&
isIdentifiedObject(KillingUndObj)) {
uint64_t KillingUndObjSize = getPointerSize(KillingUndObj, DL, TLI, &F);
if (KillingUndObjSize != MemoryLocation::UnknownSize &&
KillingUndObjSize == KillingLocSize.getValue())
std::optional<uint64_t> KillingUndObjSize =
getPointerSize(KillingUndObj, DL, TLI, &F);
if (KillingUndObjSize && *KillingUndObjSize == KillingLocSize.getValue())
return OW_Complete;
}

Expand Down

0 comments on commit d95d1c3

Please sign in to comment.