@@ -81,9 +81,6 @@ char GenericAddressAnalysis::ID = 0;
8181
8282bool GenericAddressAnalysis::runOnFunction (Function& F)
8383{
84- bool noLocalAddresses = true ;
85- bool ptrASGeneric = false ;
86-
8784 for (auto & BB : F.getBasicBlockList ()) {
8885 for (auto & Inst : BB.getInstList ()) {
8986 Type* Ty = Inst.getType ();
@@ -97,30 +94,11 @@ bool GenericAddressAnalysis::runOnFunction(Function& F)
9794 Ty = GEP->getPointerOperandType ();
9895 auto PT = dyn_cast<PointerType>(Ty);
9996 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 ;
10998 }
11099 }
111100 }
112101
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-
124102 return false ;
125103}
126104
@@ -150,13 +128,13 @@ namespace {
150128
151129 virtual bool runOnFunction (Function& F) override ;
152130
153- bool visitLoadStoreInst (Instruction& I, bool const noLocalAddresses );
131+ bool visitLoadStoreInst (Instruction& I);
154132 bool visitIntrinsicCall (CallInst& I);
155133 Module* getModule () { return m_module; }
156134
157135 private:
158136 Type* getPointerAsIntType (LLVMContext& Ctx, unsigned AS);
159- void resolveGAS (Instruction& I, Value* pointerOperand, bool const noLocalAddresses );
137+ void resolveGAS (Instruction& I, Value* pointerOperand);
160138 void resolveGASWithoutBranches (Instruction& I, Value* pointerOperand);
161139 bool allowArithmeticOnGenericAddressSpace (Function& F);
162140 AddrSpaceCastInst* findAddressSpaceCastDef (Instruction* instruction, unsigned step);
@@ -182,9 +160,6 @@ bool GenericAddressDynamicResolution::runOnFunction(Function& F)
182160 bool modified = false ;
183161 bool changed = false ;
184162
185- ModuleMetaData* const modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData ();
186- bool const noLocalAddresses = modMD->FuncMD [ &F ].openCLNoLocalAddresses ;
187-
188163 modified = allowArithmeticOnGenericAddressSpace (F);
189164
190165 // iterate for all the intrinisics used by to_local, to_global, and to_private
@@ -213,7 +188,7 @@ bool GenericAddressDynamicResolution::runOnFunction(Function& F)
213188 Instruction& instruction = (*i);
214189
215190 if (isa<LoadInst>(instruction) || isa<StoreInst>(instruction)) {
216- changed = visitLoadStoreInst (instruction, noLocalAddresses );
191+ changed = visitLoadStoreInst (instruction);
217192 }
218193
219194 if (changed) {
@@ -234,7 +209,7 @@ Type* GenericAddressDynamicResolution::getPointerAsIntType(LLVMContext& ctx, con
234209 return IntegerType::get (ctx, ptrBits);
235210}
236211
237- bool GenericAddressDynamicResolution::visitLoadStoreInst (Instruction& I, bool const noLocalAddresses )
212+ bool GenericAddressDynamicResolution::visitLoadStoreInst (Instruction& I)
238213{
239214 bool changed = false ;
240215
@@ -254,22 +229,21 @@ bool GenericAddressDynamicResolution::visitLoadStoreInst(Instruction& I, bool co
254229 }
255230
256231 if (pointerAddressSpace == ADDRESS_SPACE_GENERIC) {
257- if (m_ctx->forceGlobalMemoryAllocation () && (
258- m_ctx->hasNoLocalToGenericCast () || noLocalAddresses))
232+ if (m_ctx->forceGlobalMemoryAllocation () && m_ctx->hasNoLocalToGenericCast ())
259233 {
260234 resolveGASWithoutBranches (I, pointerOperand);
261235 }
262236 else
263237 {
264- resolveGAS (I, pointerOperand, noLocalAddresses );
238+ resolveGAS (I, pointerOperand);
265239 }
266240 changed = true ;
267241 }
268242
269243 return changed;
270244}
271245
272- void GenericAddressDynamicResolution::resolveGAS (Instruction& I, Value* pointerOperand, bool const noLocalAddresses )
246+ void GenericAddressDynamicResolution::resolveGAS (Instruction& I, Value* pointerOperand)
273247{
274248 // Every time there is a load/store from/to a generic pointer, we have to resolve
275249 // its corresponding address space by looking at its tag on bits[61:63].
@@ -318,7 +292,7 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
318292 }
319293
320294 // Local Branch
321- if (!( m_ctx->hasNoLocalToGenericCast () || noLocalAddresses ))
295+ if (!m_ctx->hasNoLocalToGenericCast ())
322296 {
323297 localBlock = BasicBlock::Create (I.getContext (), " LocalBlock" , convergeBlock->getParent (), convergeBlock);
324298 // Local
@@ -360,7 +334,7 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
360334 builder.SetInsertPoint (currentBlock);
361335
362336 // Local branch can be saved if there are no local to generic casts
363- if (m_ctx->hasNoLocalToGenericCast () || noLocalAddresses )
337+ if (m_ctx->hasNoLocalToGenericCast ())
364338 {
365339 SwitchInst* switchTag = builder.CreateSwitch (tag, globalBlock, 1 );
366340 // Based on tag there are two cases 001: private, 000/111: global
0 commit comments