[MemoryLocation] Move DSE intrinsic handling to MemoryLocation. (NFC)

Suggested in D114872.
This commit is contained in:
Florian Hahn 2021-12-03 16:00:39 +00:00
parent 71405d90f0
commit ead3979a92
No known key found for this signature in database
GPG Key ID: EEF712BB5E80EBBA
2 changed files with 13 additions and 11 deletions

View File

@ -130,8 +130,19 @@ MemoryLocation MemoryLocation::getForDest(const AnyMemIntrinsic *MI) {
Optional<MemoryLocation>
MemoryLocation::getForDest(const CallBase *CB, const TargetLibraryInfo &TLI) {
if (auto *MemInst = dyn_cast<AnyMemIntrinsic>(CB))
return getForDest(MemInst);
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(CB)) {
if (auto *MemInst = dyn_cast<AnyMemIntrinsic>(CB))
return getForDest(MemInst);
switch (II->getIntrinsicID()) {
default:
return None;
case Intrinsic::init_trampoline:
return MemoryLocation::getForArgument(CB, 0, TLI);
case Intrinsic::masked_store:
return MemoryLocation::getForArgument(CB, 1, TLI);
}
}
LibFunc LF;
if (TLI.getLibFunc(*CB, LF) && TLI.has(LF)) {

View File

@ -1032,15 +1032,6 @@ struct DSEState {
!CB->onlyAccessesInaccessibleMemOrArgMem())
return None;
switch (CB->getIntrinsicID()) {
case Intrinsic::init_trampoline:
return {MemoryLocation::getAfter(CB->getArgOperand(0))};
case Intrinsic::masked_store:
return {MemoryLocation::getForArgument(CB, 1, TLI)};
default:
break;
}
return MemoryLocation::getForDest(CB, TLI);
}