@@ -32,8 +32,7 @@ namespace {
3232
3333// / Data structure holding function info for kernels.
3434class KernelInfo {
35- void updateForBB (const BasicBlock &BB, int64_t Direction,
36- OptimizationRemarkEmitter &ORE);
35+ void updateForBB (const BasicBlock &BB, OptimizationRemarkEmitter &ORE);
3736
3837public:
3938 static void emitKernelInfo (Function &F, FunctionAnalysisManager &FAM,
@@ -180,38 +179,37 @@ static void remarkFlatAddrspaceAccess(OptimizationRemarkEmitter &ORE,
180179 });
181180}
182181
183- void KernelInfo::updateForBB (const BasicBlock &BB, int64_t Direction,
182+ void KernelInfo::updateForBB (const BasicBlock &BB,
184183 OptimizationRemarkEmitter &ORE) {
185- assert (Direction == 1 || Direction == -1 );
186184 const Function &F = *BB.getParent ();
187185 const Module &M = *F.getParent ();
188186 const DataLayout &DL = M.getDataLayout ();
189187 for (const Instruction &I : BB.instructionsWithoutDebug ()) {
190188 if (const AllocaInst *Alloca = dyn_cast<AllocaInst>(&I)) {
191- Allocas += Direction ;
189+ ++Allocas ;
192190 TypeSize::ScalarTy StaticSize = 0 ;
193191 if (std::optional<TypeSize> Size = Alloca->getAllocationSize (DL)) {
194192 StaticSize = Size->getFixedValue ();
195193 assert (StaticSize <= std::numeric_limits<int64_t >::max ());
196- AllocasStaticSizeSum += Direction * StaticSize;
194+ AllocasStaticSizeSum += StaticSize;
197195 } else {
198- AllocasDyn += Direction ;
196+ ++AllocasDyn ;
199197 }
200198 remarkAlloca (ORE, F, *Alloca, StaticSize);
201199 } else if (const CallBase *Call = dyn_cast<CallBase>(&I)) {
202200 SmallString<40 > CallKind;
203201 SmallString<40 > RemarkKind;
204202 if (Call->isIndirectCall ()) {
205- IndirectCalls += Direction ;
203+ ++IndirectCalls ;
206204 CallKind += " indirect" ;
207205 RemarkKind += " Indirect" ;
208206 } else {
209- DirectCalls += Direction ;
207+ ++DirectCalls ;
210208 CallKind += " direct" ;
211209 RemarkKind += " Direct" ;
212210 }
213211 if (isa<InvokeInst>(Call)) {
214- Invokes += Direction ;
212+ ++Invokes ;
215213 CallKind += " invoke" ;
216214 RemarkKind += " Invoke" ;
217215 } else {
@@ -221,47 +219,47 @@ void KernelInfo::updateForBB(const BasicBlock &BB, int64_t Direction,
221219 if (!Call->isIndirectCall ()) {
222220 if (const Function *Callee = Call->getCalledFunction ()) {
223221 if (!Callee->isIntrinsic () && !Callee->isDeclaration ()) {
224- DirectCallsToDefinedFunctions += Direction ;
222+ ++DirectCallsToDefinedFunctions ;
225223 CallKind += " to defined function" ;
226224 RemarkKind += " ToDefinedFunction" ;
227225 }
228226 } else if (Call->isInlineAsm ()) {
229- InlineAssemblyCalls += Direction ;
227+ ++InlineAssemblyCalls ;
230228 CallKind += " to inline assembly" ;
231229 RemarkKind += " ToInlineAssembly" ;
232230 }
233231 }
234232 remarkCall (ORE, F, *Call, CallKind, RemarkKind);
235233 if (const AnyMemIntrinsic *MI = dyn_cast<AnyMemIntrinsic>(Call)) {
236234 if (MI->getDestAddressSpace () == FlatAddrspace) {
237- FlatAddrspaceAccesses += Direction ;
235+ ++FlatAddrspaceAccesses ;
238236 remarkFlatAddrspaceAccess (ORE, F, I);
239237 } else if (const AnyMemTransferInst *MT =
240238 dyn_cast<AnyMemTransferInst>(MI)) {
241239 if (MT->getSourceAddressSpace () == FlatAddrspace) {
242- FlatAddrspaceAccesses += Direction ;
240+ ++FlatAddrspaceAccesses ;
243241 remarkFlatAddrspaceAccess (ORE, F, I);
244242 }
245243 }
246244 }
247245 } else if (const LoadInst *Load = dyn_cast<LoadInst>(&I)) {
248246 if (Load->getPointerAddressSpace () == FlatAddrspace) {
249- FlatAddrspaceAccesses += Direction ;
247+ ++FlatAddrspaceAccesses ;
250248 remarkFlatAddrspaceAccess (ORE, F, I);
251249 }
252250 } else if (const StoreInst *Store = dyn_cast<StoreInst>(&I)) {
253251 if (Store->getPointerAddressSpace () == FlatAddrspace) {
254- FlatAddrspaceAccesses += Direction ;
252+ ++FlatAddrspaceAccesses ;
255253 remarkFlatAddrspaceAccess (ORE, F, I);
256254 }
257255 } else if (const AtomicRMWInst *At = dyn_cast<AtomicRMWInst>(&I)) {
258256 if (At->getPointerAddressSpace () == FlatAddrspace) {
259- FlatAddrspaceAccesses += Direction ;
257+ ++FlatAddrspaceAccesses ;
260258 remarkFlatAddrspaceAccess (ORE, F, I);
261259 }
262260 } else if (const AtomicCmpXchgInst *At = dyn_cast<AtomicCmpXchgInst>(&I)) {
263261 if (At->getPointerAddressSpace () == FlatAddrspace) {
264- FlatAddrspaceAccesses += Direction ;
262+ ++FlatAddrspaceAccesses ;
265263 remarkFlatAddrspaceAccess (ORE, F, I);
266264 }
267265 }
@@ -300,11 +298,9 @@ void KernelInfo::emitKernelInfo(Function &F, FunctionAnalysisManager &FAM,
300298 }
301299 TheTTI.collectKernelLaunchBounds (F, KI.LaunchBounds );
302300
303- const DominatorTree &DT = FAM.getResult <DominatorTreeAnalysis>(F);
304301 auto &ORE = FAM.getResult <OptimizationRemarkEmitterAnalysis>(F);
305302 for (const auto &BB : F)
306- if (DT.isReachableFromEntry (&BB))
307- KI.updateForBB (BB, +1 , ORE);
303+ KI.updateForBB (BB, ORE);
308304
309305#define REMARK_PROPERTY (PROP_NAME ) \
310306 remarkProperty (ORE, F, #PROP_NAME, KI.PROP_NAME )
0 commit comments