Internal performance refinements

Improvements to internal analysis and data handling to reduce overhead.
This commit is contained in:
Jakacki, Jakub
2025-09-15 17:30:45 +00:00
committed by igcbot
parent 7ad819c853
commit 009c253d4f
2 changed files with 29 additions and 10 deletions

View File

@ -33,7 +33,7 @@ using namespace llvm;
using namespace IGC;
AllocationLivenessAnalyzer::LivenessData
AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT, LoopInfo &LI) {
AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT, LoopInfo &LI, bool includeOrigin) {
// static allocas are usually going to be in the entry block
// that's a practice, but we only care about the last block that dominates all uses
BasicBlock *commonDominator = nullptr;
@ -93,14 +93,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
}
}
} break;
case Instruction::Call: {
auto *callI = cast<CallInst>(II);
if (!callI->doesNotCapture(use->getOperandNo()))
lifetimeLeakingUsers.insert(II);
if (II->getType()->isPointerTy())
addUsesFn(II->uses());
} break;
case Instruction::Call:
implementCallSpecificBehavior(cast<CallInst>(II), use, worklist, allUsers, lifetimeLeakingUsers);
break;
case Instruction::Load:
if (II->getType()->isPointerTy())
addUsesFn(II->uses());
@ -111,6 +106,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
}
}
if (includeOrigin)
allUsers.insert(I);
return LivenessData(I, std::move(allUsers), LI, DT, commonDominator, std::move(lifetimeLeakingUsers));
}
@ -120,6 +118,20 @@ void AllocationLivenessAnalyzer::getAnalysisUsage(llvm::AnalysisUsage &AU) const
getAdditionalAnalysisUsage(AU);
}
void AllocationLivenessAnalyzer::implementCallSpecificBehavior(CallInst *callI, Use* use, SmallVector<Use *> &worklist,
SetVector<Instruction *> &allUsers,
SetVector<Instruction *> &lifetimeLeakingUsers) {
if (!callI->doesNotCapture(use->getOperandNo()))
lifetimeLeakingUsers.insert(callI);
if (callI->getType()->isPointerTy()) {
for (auto &use : callI->uses())
worklist.push_back(&use);
}
}
template <typename range>
static inline void doWorkLoop(SmallVector<BasicBlock *> &worklist, DenseSet<BasicBlock *> &bbSet1,
DenseSet<BasicBlock *> &bbSet2, std::function<range(BasicBlock *)> iterate,

View File

@ -15,9 +15,11 @@ SPDX-License-Identifier: MIT
namespace llvm {
class BasicBlock;
class CallInst;
class DominatorTree;
class Instruction;
class LoopInfo;
class Use;
} // namespace llvm
namespace IGC {
@ -49,10 +51,15 @@ public:
AllocationLivenessAnalyzer(char &pid) : llvm::FunctionPass(pid) {}
protected:
LivenessData ProcessInstruction(llvm::Instruction *I, llvm::DominatorTree &DT, llvm::LoopInfo &LI);
LivenessData ProcessInstruction(llvm::Instruction *I, llvm::DominatorTree &DT, llvm::LoopInfo &LI,
bool includeOrigin = false);
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
virtual void getAdditionalAnalysisUsage(llvm::AnalysisUsage &AU) const = 0;
virtual void implementCallSpecificBehavior(llvm::CallInst *I, llvm::Use *use,
llvm::SmallVector<llvm::Use *> &worklist,
llvm::SetVector<llvm::Instruction *> &allUsers,
llvm::SetVector<llvm::Instruction *> &lifetimeLeakingUsers);
};
namespace Provenance {