#include "llvm/CodeGen/GlobalISel/LoadStoreOpt.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/MemoryLocation.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/LowLevelTypeUtils.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Register.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespaceore;
usingnamespaceMIPatternMatch;
STATISTIC(NumStoresMerged, "Number of stores merged");
const unsigned MaxStoreSizeToForm = …;
char LoadStoreOpt::ID = …;
INITIALIZE_PASS_BEGIN(LoadStoreOpt, DEBUG_TYPE, "Generic memory optimizations",
false, false)
INITIALIZE_PASS_END(LoadStoreOpt, DEBUG_TYPE, "Generic memory optimizations",
false, false)
LoadStoreOpt::LoadStoreOpt(std::function<bool(const MachineFunction &)> F)
: … { … }
LoadStoreOpt::LoadStoreOpt()
: … { … }
void LoadStoreOpt::init(MachineFunction &MF) { … }
void LoadStoreOpt::getAnalysisUsage(AnalysisUsage &AU) const { … }
BaseIndexOffset GISelAddressing::getPointerInfo(Register Ptr,
MachineRegisterInfo &MRI) { … }
bool GISelAddressing::aliasIsKnownForLoadStore(const MachineInstr &MI1,
const MachineInstr &MI2,
bool &IsAlias,
MachineRegisterInfo &MRI) { … }
bool GISelAddressing::instMayAlias(const MachineInstr &MI,
const MachineInstr &Other,
MachineRegisterInfo &MRI,
AliasAnalysis *AA) { … }
static bool isInstHardMergeHazard(MachineInstr &MI) { … }
bool LoadStoreOpt::mergeStores(SmallVectorImpl<GStore *> &StoresToMerge) { … }
bool LoadStoreOpt::isLegalOrBeforeLegalizer(const LegalityQuery &Query,
MachineFunction &MF) const { … }
bool LoadStoreOpt::doSingleStoreMerge(SmallVectorImpl<GStore *> &Stores) { … }
bool LoadStoreOpt::processMergeCandidate(StoreMergeCandidate &C) { … }
bool LoadStoreOpt::operationAliasesWithCandidate(MachineInstr &MI,
StoreMergeCandidate &C) { … }
void LoadStoreOpt::StoreMergeCandidate::addPotentialAlias(MachineInstr &MI) { … }
bool LoadStoreOpt::addStoreToCandidate(GStore &StoreMI,
StoreMergeCandidate &C) { … }
bool LoadStoreOpt::mergeBlockStores(MachineBasicBlock &MBB) { … }
static std::optional<int64_t>
getTruncStoreByteOffset(GStore &Store, Register &SrcVal,
MachineRegisterInfo &MRI) { … }
bool LoadStoreOpt::mergeTruncStore(GStore &StoreMI,
SmallPtrSetImpl<GStore *> &DeletedStores) { … }
bool LoadStoreOpt::mergeTruncStoresBlock(MachineBasicBlock &BB) { … }
bool LoadStoreOpt::mergeFunctionStores(MachineFunction &MF) { … }
void LoadStoreOpt::initializeStoreMergeTargetInfo(unsigned AddrSpace) { … }
bool LoadStoreOpt::runOnMachineFunction(MachineFunction &MF) { … }