@@ -81,9 +81,6 @@ char GenericAddressAnalysis::ID = 0;
81
81
82
82
bool GenericAddressAnalysis::runOnFunction (Function& F)
83
83
{
84
- bool noLocalAddresses = true ;
85
- bool ptrASGeneric = false ;
86
-
87
84
for (auto & BB : F.getBasicBlockList ()) {
88
85
for (auto & Inst : BB.getInstList ()) {
89
86
Type* Ty = Inst.getType ();
@@ -97,30 +94,11 @@ bool GenericAddressAnalysis::runOnFunction(Function& F)
97
94
Ty = GEP->getPointerOperandType ();
98
95
auto PT = dyn_cast<PointerType>(Ty);
99
96
if (PT && PT->getAddressSpace () == ADDRESS_SPACE_GENERIC) {
100
- ptrASGeneric = true ;
101
- }
102
- if ( PT && PT->getAddressSpace () == ADDRESS_SPACE_LOCAL ) {
103
- noLocalAddresses = false ;
104
- }
105
- // if all analysis concluded then break further processing
106
- if ( ptrASGeneric && !noLocalAddresses )
107
- {
108
- break ;
97
+ return true ;
109
98
}
110
99
}
111
100
}
112
101
113
- // if local addresses do not occur, then set flag in function metadata
114
- if ( noLocalAddresses ) {
115
- ModuleMetaData* const modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData ();
116
- modMD->FuncMD [ &F ].openCLNoLocalAddresses = true ;
117
- }
118
-
119
- if ( ptrASGeneric )
120
- {
121
- return true ;
122
- }
123
-
124
102
return false ;
125
103
}
126
104
@@ -150,13 +128,13 @@ namespace {
150
128
151
129
virtual bool runOnFunction (Function& F) override ;
152
130
153
- bool visitLoadStoreInst (Instruction& I, bool const noLocalAddresses );
131
+ bool visitLoadStoreInst (Instruction& I);
154
132
bool visitIntrinsicCall (CallInst& I);
155
133
Module* getModule () { return m_module; }
156
134
157
135
private:
158
136
Type* getPointerAsIntType (LLVMContext& Ctx, unsigned AS);
159
- void resolveGAS (Instruction& I, Value* pointerOperand, bool const noLocalAddresses );
137
+ void resolveGAS (Instruction& I, Value* pointerOperand);
160
138
void resolveGASWithoutBranches (Instruction& I, Value* pointerOperand);
161
139
bool allowArithmeticOnGenericAddressSpace (Function& F);
162
140
AddrSpaceCastInst* findAddressSpaceCastDef (Instruction* instruction, unsigned step);
@@ -182,9 +160,6 @@ bool GenericAddressDynamicResolution::runOnFunction(Function& F)
182
160
bool modified = false ;
183
161
bool changed = false ;
184
162
185
- ModuleMetaData* const modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData ();
186
- bool const noLocalAddresses = modMD->FuncMD [ &F ].openCLNoLocalAddresses ;
187
-
188
163
modified = allowArithmeticOnGenericAddressSpace (F);
189
164
190
165
// iterate for all the intrinisics used by to_local, to_global, and to_private
@@ -213,7 +188,7 @@ bool GenericAddressDynamicResolution::runOnFunction(Function& F)
213
188
Instruction& instruction = (*i);
214
189
215
190
if (isa<LoadInst>(instruction) || isa<StoreInst>(instruction)) {
216
- changed = visitLoadStoreInst (instruction, noLocalAddresses );
191
+ changed = visitLoadStoreInst (instruction);
217
192
}
218
193
219
194
if (changed) {
@@ -234,7 +209,7 @@ Type* GenericAddressDynamicResolution::getPointerAsIntType(LLVMContext& ctx, con
234
209
return IntegerType::get (ctx, ptrBits);
235
210
}
236
211
237
- bool GenericAddressDynamicResolution::visitLoadStoreInst (Instruction& I, bool const noLocalAddresses )
212
+ bool GenericAddressDynamicResolution::visitLoadStoreInst (Instruction& I)
238
213
{
239
214
bool changed = false ;
240
215
@@ -254,22 +229,21 @@ bool GenericAddressDynamicResolution::visitLoadStoreInst(Instruction& I, bool co
254
229
}
255
230
256
231
if (pointerAddressSpace == ADDRESS_SPACE_GENERIC) {
257
- if (m_ctx->forceGlobalMemoryAllocation () && (
258
- m_ctx->hasNoLocalToGenericCast () || noLocalAddresses))
232
+ if (m_ctx->forceGlobalMemoryAllocation () && m_ctx->hasNoLocalToGenericCast ())
259
233
{
260
234
resolveGASWithoutBranches (I, pointerOperand);
261
235
}
262
236
else
263
237
{
264
- resolveGAS (I, pointerOperand, noLocalAddresses );
238
+ resolveGAS (I, pointerOperand);
265
239
}
266
240
changed = true ;
267
241
}
268
242
269
243
return changed;
270
244
}
271
245
272
- void GenericAddressDynamicResolution::resolveGAS (Instruction& I, Value* pointerOperand, bool const noLocalAddresses )
246
+ void GenericAddressDynamicResolution::resolveGAS (Instruction& I, Value* pointerOperand)
273
247
{
274
248
// Every time there is a load/store from/to a generic pointer, we have to resolve
275
249
// its corresponding address space by looking at its tag on bits[61:63].
@@ -318,7 +292,7 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
318
292
}
319
293
320
294
// Local Branch
321
- if (!( m_ctx->hasNoLocalToGenericCast () || noLocalAddresses ))
295
+ if (!m_ctx->hasNoLocalToGenericCast ())
322
296
{
323
297
localBlock = BasicBlock::Create (I.getContext (), " LocalBlock" , convergeBlock->getParent (), convergeBlock);
324
298
// Local
@@ -360,7 +334,7 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
360
334
builder.SetInsertPoint (currentBlock);
361
335
362
336
// Local branch can be saved if there are no local to generic casts
363
- if (m_ctx->hasNoLocalToGenericCast () || noLocalAddresses )
337
+ if (m_ctx->hasNoLocalToGenericCast ())
364
338
{
365
339
SwitchInst* switchTag = builder.CreateSwitch (tag, globalBlock, 1 );
366
340
// Based on tag there are two cases 001: private, 000/111: global
0 commit comments