Skip to content

Commit 009c253

Browse files
jaladreipsigcbot
authored andcommitted
Internal performance refinements
Improvements to internal analysis and data handling to reduce overhead.
1 parent 7ad819c commit 009c253

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

IGC/AdaptorCommon/LivenessUtils/AllocationLivenessAnalyzer.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using namespace llvm;
3333
using namespace IGC;
3434

3535
AllocationLivenessAnalyzer::LivenessData
36-
AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT, LoopInfo &LI) {
36+
AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT, LoopInfo &LI, bool includeOrigin) {
3737
// static allocas are usually going to be in the entry block
3838
// that's a practice, but we only care about the last block that dominates all uses
3939
BasicBlock *commonDominator = nullptr;
@@ -93,14 +93,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
9393
}
9494
}
9595
} break;
96-
case Instruction::Call: {
97-
auto *callI = cast<CallInst>(II);
98-
if (!callI->doesNotCapture(use->getOperandNo()))
99-
lifetimeLeakingUsers.insert(II);
100-
101-
if (II->getType()->isPointerTy())
102-
addUsesFn(II->uses());
103-
} break;
96+
case Instruction::Call:
97+
implementCallSpecificBehavior(cast<CallInst>(II), use, worklist, allUsers, lifetimeLeakingUsers);
98+
break;
10499
case Instruction::Load:
105100
if (II->getType()->isPointerTy())
106101
addUsesFn(II->uses());
@@ -111,6 +106,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
111106
}
112107
}
113108

109+
if (includeOrigin)
110+
allUsers.insert(I);
111+
114112
return LivenessData(I, std::move(allUsers), LI, DT, commonDominator, std::move(lifetimeLeakingUsers));
115113
}
116114

@@ -120,6 +118,20 @@ void AllocationLivenessAnalyzer::getAnalysisUsage(llvm::AnalysisUsage &AU) const
120118
getAdditionalAnalysisUsage(AU);
121119
}
122120

121+
void AllocationLivenessAnalyzer::implementCallSpecificBehavior(CallInst *callI, Use* use, SmallVector<Use *> &worklist,
122+
SetVector<Instruction *> &allUsers,
123+
SetVector<Instruction *> &lifetimeLeakingUsers) {
124+
125+
if (!callI->doesNotCapture(use->getOperandNo()))
126+
lifetimeLeakingUsers.insert(callI);
127+
128+
if (callI->getType()->isPointerTy()) {
129+
130+
for (auto &use : callI->uses())
131+
worklist.push_back(&use);
132+
}
133+
}
134+
123135
template <typename range>
124136
static inline void doWorkLoop(SmallVector<BasicBlock *> &worklist, DenseSet<BasicBlock *> &bbSet1,
125137
DenseSet<BasicBlock *> &bbSet2, std::function<range(BasicBlock *)> iterate,

IGC/AdaptorCommon/LivenessUtils/AllocationLivenessAnalyzer.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ SPDX-License-Identifier: MIT
1515

1616
namespace llvm {
1717
class BasicBlock;
18+
class CallInst;
1819
class DominatorTree;
1920
class Instruction;
2021
class LoopInfo;
22+
class Use;
2123
} // namespace llvm
2224

2325
namespace IGC {
@@ -49,10 +51,15 @@ class AllocationLivenessAnalyzer : public llvm::FunctionPass {
4951
AllocationLivenessAnalyzer(char &pid) : llvm::FunctionPass(pid) {}
5052

5153
protected:
52-
LivenessData ProcessInstruction(llvm::Instruction *I, llvm::DominatorTree &DT, llvm::LoopInfo &LI);
54+
LivenessData ProcessInstruction(llvm::Instruction *I, llvm::DominatorTree &DT, llvm::LoopInfo &LI,
55+
bool includeOrigin = false);
5356

5457
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
5558
virtual void getAdditionalAnalysisUsage(llvm::AnalysisUsage &AU) const = 0;
59+
virtual void implementCallSpecificBehavior(llvm::CallInst *I, llvm::Use *use,
60+
llvm::SmallVector<llvm::Use *> &worklist,
61+
llvm::SetVector<llvm::Instruction *> &allUsers,
62+
llvm::SetVector<llvm::Instruction *> &lifetimeLeakingUsers);
5663
};
5764

5865
namespace Provenance {

0 commit comments

Comments
 (0)