@@ -122,8 +122,6 @@ class Lint : public InstVisitor<Lint> {
122122 Value *findValue (Value *V, bool OffsetOk) const ;
123123 Value *findValueImpl (Value *V, bool OffsetOk,
124124 SmallPtrSetImpl<Value *> &Visited) const ;
125-
126- bool isConstantAddressSpace (unsigned AS) const ;
127125public:
128126 Module *Mod;
129127 Triple TT;
@@ -382,36 +380,6 @@ void Lint::visitReturnInst(ReturnInst &I) {
382380 }
383381}
384382
385- bool Lint::isConstantAddressSpace (unsigned AS) const {
386- if (TT.isAMDGPU ()) {
387- switch (AS) {
388- using namespace AMDGPUAS ;
389- case CONSTANT_ADDRESS:
390- case CONSTANT_ADDRESS_32BIT:
391- case CONSTANT_BUFFER_0:
392- case CONSTANT_BUFFER_1:
393- case CONSTANT_BUFFER_2:
394- case CONSTANT_BUFFER_3:
395- case CONSTANT_BUFFER_4:
396- case CONSTANT_BUFFER_5:
397- case CONSTANT_BUFFER_6:
398- case CONSTANT_BUFFER_7:
399- case CONSTANT_BUFFER_8:
400- case CONSTANT_BUFFER_9:
401- case CONSTANT_BUFFER_10:
402- case CONSTANT_BUFFER_11:
403- case CONSTANT_BUFFER_12:
404- case CONSTANT_BUFFER_13:
405- case CONSTANT_BUFFER_14:
406- case CONSTANT_BUFFER_15:
407- return true ;
408- default :
409- return false ;
410- }
411- }
412- return false ;
413- }
414-
415383// TODO: Check that the reference is in bounds.
416384// TODO: Check readnone/readonly function attributes.
417385void Lint::visitMemoryReference (Instruction &I, const MemoryLocation &Loc,
@@ -435,8 +403,9 @@ void Lint::visitMemoryReference(Instruction &I, const MemoryLocation &Loc,
435403 " Unusual: Address one pointer dereference" , &I);
436404
437405 if (Flags & MemRef::Write) {
438- Check (!isConstantAddressSpace (UnderlyingObject->getType ()->getPointerAddressSpace ()),
439- " Undefined behavior: Write to const memory" , &I);
406+ if (TT.isAMDGPU ())
407+ Check (!AMDGPU::isConstantAddressSpace (UnderlyingObject->getType ()->getPointerAddressSpace ()),
408+ " Undefined behavior: Write to const memory" , &I);
440409
441410 if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(UnderlyingObject))
442411 Check (!GV->isConstant (), " Undefined behavior: Write to read-only memory" ,
0 commit comments