@@ -33,7 +33,7 @@ using namespace llvm;
33
33
using namespace IGC ;
34
34
35
35
AllocationLivenessAnalyzer::LivenessData
36
- AllocationLivenessAnalyzer::ProcessInstruction (Instruction *I, DominatorTree &DT, LoopInfo &LI) {
36
+ AllocationLivenessAnalyzer::ProcessInstruction (Instruction *I, DominatorTree &DT, LoopInfo &LI, bool includeOrigin ) {
37
37
// static allocas are usually going to be in the entry block
38
38
// that's a practice, but we only care about the last block that dominates all uses
39
39
BasicBlock *commonDominator = nullptr ;
@@ -93,14 +93,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
93
93
}
94
94
}
95
95
} 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 ;
104
99
case Instruction::Load:
105
100
if (II->getType ()->isPointerTy ())
106
101
addUsesFn (II->uses ());
@@ -111,6 +106,9 @@ AllocationLivenessAnalyzer::ProcessInstruction(Instruction *I, DominatorTree &DT
111
106
}
112
107
}
113
108
109
+ if (includeOrigin)
110
+ allUsers.insert (I);
111
+
114
112
return LivenessData (I, std::move (allUsers), LI, DT, commonDominator, std::move (lifetimeLeakingUsers));
115
113
}
116
114
@@ -120,6 +118,20 @@ void AllocationLivenessAnalyzer::getAnalysisUsage(llvm::AnalysisUsage &AU) const
120
118
getAdditionalAnalysisUsage (AU);
121
119
}
122
120
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
+
123
135
template <typename range>
124
136
static inline void doWorkLoop (SmallVector<BasicBlock *> &worklist, DenseSet<BasicBlock *> &bbSet1,
125
137
DenseSet<BasicBlock *> &bbSet2, std::function<range(BasicBlock *)> iterate,
0 commit comments