@@ -53,7 +53,7 @@ char CheckInstrTypes::ID = 0;
53
53
CheckInstrTypes::CheckInstrTypes (IGC::SInstrTypes* instrList) : FunctionPass(ID), g_InstrTypes(instrList)
54
54
{
55
55
initializeLoopInfoWrapperPassPass (*PassRegistry::getPassRegistry ());
56
- initializeCheckInstrTypesPass (*PassRegistry::getPassRegistry ());
56
+ initializeCheckInstrTypesPass (*PassRegistry::getPassRegistry ());
57
57
58
58
instrList->CorrelatedValuePropagationEnable = false ;
59
59
instrList->hasLoop = false ;
@@ -68,6 +68,7 @@ CheckInstrTypes::CheckInstrTypes(IGC::SInstrTypes* instrList) : FunctionPass(ID)
68
68
instrList->hasFunctionAddressTaken = false ;
69
69
instrList->hasSel = false ;
70
70
instrList->hasPointer = false ;
71
+ instrList->hasGenericAddressSpacePointers = false ;
71
72
instrList->hasLocalLoadStore = false ;
72
73
instrList->hasSubroutines = false ;
73
74
instrList->hasPrimitiveAlloca = false ;
@@ -79,13 +80,13 @@ CheckInstrTypes::CheckInstrTypes(IGC::SInstrTypes* instrList) : FunctionPass(ID)
79
80
instrList->hasBarrier = false ;
80
81
instrList->hasDiscard = false ;
81
82
instrList->mayHaveIndirectOperands = false ;
82
- instrList->numSample = 0 ;
83
- instrList->numBB = 0 ;
84
- instrList->numLoopInsts = 0 ;
83
+ instrList->numSample = 0 ;
84
+ instrList->numBB = 0 ;
85
+ instrList->numLoopInsts = 0 ;
85
86
instrList->numOfLoop = 0 ;
86
87
instrList->numInsts = 0 ;
87
- instrList->sampleCmpToDiscardOptimizationPossible = false ;
88
- instrList->sampleCmpToDiscardOptimizationSlot = 0 ;
88
+ instrList->sampleCmpToDiscardOptimizationPossible = false ;
89
+ instrList->sampleCmpToDiscardOptimizationSlot = 0 ;
89
90
}
90
91
91
92
void CheckInstrTypes::SetLoopFlags (Function &F)
@@ -116,15 +117,22 @@ bool CheckInstrTypes::runOnFunction(Function &F)
116
117
g_InstrTypes->hasDebugInfo = F.getParent ()->getNamedMetadata (" llvm.dbg.cu" ) != nullptr ;
117
118
118
119
visit (F);
119
- SetLoopFlags (F);
120
+ SetLoopFlags (F);
120
121
return false ;
121
122
}
122
123
123
- void CheckInstrTypes::visitInstruction (llvm::Instruction &I) {
124
+ void CheckInstrTypes::visitInstruction (llvm::Instruction &I)
125
+ {
124
126
if (!llvm::isa<llvm::DbgInfoIntrinsic>(&I))
125
127
{
126
128
g_InstrTypes->numInsts ++;
127
129
}
130
+
131
+ auto PT = dyn_cast<PointerType>(I.getType ());
132
+ if (PT && PT->getPointerAddressSpace () == ADDRESS_SPACE_GENERIC)
133
+ {
134
+ g_InstrTypes->hasGenericAddressSpacePointers = true ;
135
+ }
128
136
}
129
137
130
138
void CheckInstrTypes::visitCallInst (CallInst &C)
@@ -245,6 +253,12 @@ void CheckInstrTypes::visitAllocaInst(AllocaInst &I)
245
253
{
246
254
g_InstrTypes->hasPrimitiveAlloca = true ;
247
255
}
256
+
257
+ auto PT = dyn_cast<PointerType>(I.getAllocatedType ());
258
+ if (PT && PT->getPointerAddressSpace () == ADDRESS_SPACE_GENERIC)
259
+ {
260
+ g_InstrTypes->hasGenericAddressSpacePointers = true ;
261
+ }
248
262
}
249
263
250
264
void CheckInstrTypes::visitLoadInst (LoadInst &I)
@@ -255,21 +269,29 @@ void CheckInstrTypes::visitLoadInst(LoadInst &I)
255
269
{
256
270
g_InstrTypes->hasLocalLoadStore = true ;
257
271
}
272
+ if (I.getPointerAddressSpace () == ADDRESS_SPACE_GENERIC)
273
+ {
274
+ g_InstrTypes->hasGenericAddressSpacePointers = true ;
275
+ }
258
276
}
259
277
260
278
void CheckInstrTypes::visitStoreInst (StoreInst &I)
261
279
{
262
280
g_InstrTypes->numInsts ++;
263
281
g_InstrTypes->hasLoadStore = true ;
264
282
uint as = I.getPointerAddressSpace ();
265
- if (as != ADDRESS_SPACE_PRIVATE)
283
+ if (as != ADDRESS_SPACE_PRIVATE)
266
284
{
267
285
g_InstrTypes->psHasSideEffect = true ;
268
286
}
269
- if (I. getPointerAddressSpace () == ADDRESS_SPACE_LOCAL)
287
+ if (as == ADDRESS_SPACE_LOCAL)
270
288
{
271
289
g_InstrTypes->hasLocalLoadStore = true ;
272
290
}
291
+ if (as == ADDRESS_SPACE_GENERIC)
292
+ {
293
+ g_InstrTypes->hasGenericAddressSpacePointers = true ;
294
+ }
273
295
}
274
296
275
297
void CheckInstrTypes::visitPHINode (PHINode &PN)
@@ -283,3 +305,12 @@ void CheckInstrTypes::visitSelectInst(SelectInst &I)
283
305
g_InstrTypes->numInsts ++;
284
306
g_InstrTypes->hasSel = true ;
285
307
}
308
+
309
+ void CheckInstrTypes::visitGetElementPtrInst (llvm::GetElementPtrInst &I)
310
+ {
311
+ g_InstrTypes->numInsts ++;
312
+ if (I.getPointerAddressSpace () == ADDRESS_SPACE_GENERIC)
313
+ {
314
+ g_InstrTypes->hasGenericAddressSpacePointers = true ;
315
+ }
316
+ }
0 commit comments