Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ class ReachingDefAnalysis : public MachineFunctionPass {
DenseMap<MachineInstr *, int> InstIds;

MBBReachingDefsInfo MBBReachingDefs;

/// MBBFrameObjsReachingDefs[{i, j}] is a list of instruction indices
/// (relative to begining of MBB i) that define frame index j in MBB i. This
/// is used in answering reaching definition queries.
using MBBFrameObjsReachingDefsInfo =
DenseMap<unsigned, DenseMap<int, SmallVector<int>>>;
// MBBFrameObjsReachingDefs[i][j] is a list of instruction indices (relative
// to begining of MBB) that define frame index (j +
// MF->getFrameInfo().getObjectIndexBegin()) in MBB i. This is used in
// answering reaching definition queries.
DenseMap<std::pair<unsigned, int>, SmallVector<int>>;
MBBFrameObjsReachingDefsInfo MBBFrameObjsReachingDefs;

/// Default values are 'nothing happened a long time ago'.
Expand Down
15 changes: 4 additions & 11 deletions llvm/lib/CodeGen/ReachingDefAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ void ReachingDefAnalysis::processDefs(MachineInstr *MI) {
assert(FrameIndex >= 0 && "Can't handle negative frame indicies yet!");
if (!isFIDef(*MI, FrameIndex, TII))
continue;

int Key = FrameIndex - ObjectIndexBegin;
MBBFrameObjsReachingDefs[MBBNumber][Key].push_back(CurInstr);
MBBFrameObjsReachingDefs[{MBBNumber, FrameIndex}].push_back(CurInstr);
}
if (!isValidRegDef(MO))
continue;
Expand Down Expand Up @@ -344,15 +342,10 @@ int ReachingDefAnalysis::getReachingDef(MachineInstr *MI, Register Reg) const {
int Key = FrameIndex - ObjectIndexBegin;

// Check that there was a reaching def.
auto Lookup1 = MBBFrameObjsReachingDefs.find(MBBNumber);
if (Lookup1 == MBBFrameObjsReachingDefs.end())
return LatestDef;
auto &InnerMap = Lookup1->second;
auto Lookup2 = InnerMap.find(Key);
if (Lookup2 == InnerMap.end())
auto Lookup = MBBFrameObjsReachingDefs.find({MBBNumber, Key});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this need to use FrameIndex instead of Key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, forgot to update. thanks

Copy link
Collaborator

@topperc topperc Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's no testing? Or is it because object begin was 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no testing for a non-zero ObjectIndexBegin, so it ended up behaving as if Key == FrameIndex. Do you want me to add a test for a non-zero ObjectIndexBegin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@topperc test added. It doesn't matter anymore though since we no longer care about ObjectIndexBegin.

if (Lookup == MBBFrameObjsReachingDefs.end())
return LatestDef;
auto &Defs = Lookup2->second;

auto &Defs = Lookup->second;
for (int Def : Defs) {
if (Def >= InstId)
break;
Expand Down
Loading