Skip to content

Commit d95d1c3

Browse files
committed
[DSE] Return std::optional from getPointerSize() (NFC)
1 parent e3adc6a commit d95d1c3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,17 @@ static bool isShortenableAtTheBeginning(Instruction *I) {
205205
return isa<AnyMemSetInst>(I);
206206
}
207207

208-
static uint64_t getPointerSize(const Value *V, const DataLayout &DL,
209-
const TargetLibraryInfo &TLI,
210-
const Function *F) {
208+
static std::optional<uint64_t> getPointerSize(const Value *V,
209+
const DataLayout &DL,
210+
const TargetLibraryInfo &TLI,
211+
const Function *F) {
211212
uint64_t Size;
212213
ObjectSizeOpts Opts;
213214
Opts.NullIsUnknownSize = NullPointerIsDefined(F);
214215

215216
if (getObjectSize(V, Size, DL, &TLI, Opts))
216217
return Size;
217-
return MemoryLocation::UnknownSize;
218+
return std::nullopt;
218219
}
219220

220221
namespace {
@@ -951,9 +952,9 @@ struct DSEState {
951952
// case the size/offset of the dead store does not matter.
952953
if (DeadUndObj == KillingUndObj && KillingLocSize.isPrecise() &&
953954
isIdentifiedObject(KillingUndObj)) {
954-
uint64_t KillingUndObjSize = getPointerSize(KillingUndObj, DL, TLI, &F);
955-
if (KillingUndObjSize != MemoryLocation::UnknownSize &&
956-
KillingUndObjSize == KillingLocSize.getValue())
955+
std::optional<uint64_t> KillingUndObjSize =
956+
getPointerSize(KillingUndObj, DL, TLI, &F);
957+
if (KillingUndObjSize && *KillingUndObjSize == KillingLocSize.getValue())
957958
return OW_Complete;
958959
}
959960

0 commit comments

Comments
 (0)