@@ -103,6 +103,8 @@ class Lint : public InstVisitor<Lint> {
103103 void visitReturnInst (ReturnInst &I);
104104 void visitLoadInst (LoadInst &I);
105105 void visitStoreInst (StoreInst &I);
106+ void visitAtomicCmpXchgInst (AtomicCmpXchgInst &I);
107+ void visitAtomicRMWInst (AtomicRMWInst &I);
106108 void visitXor (BinaryOperator &I);
107109 void visitSub (BinaryOperator &I);
108110 void visitLShr (BinaryOperator &I);
@@ -122,6 +124,7 @@ class Lint : public InstVisitor<Lint> {
122124 Value *findValue (Value *V, bool OffsetOk) const ;
123125 Value *findValueImpl (Value *V, bool OffsetOk,
124126 SmallPtrSetImpl<Value *> &Visited) const ;
127+
125128public:
126129 Module *Mod;
127130 Triple TT;
@@ -136,9 +139,8 @@ class Lint : public InstVisitor<Lint> {
136139
137140 Lint (Module *Mod, const DataLayout *DL, AliasAnalysis *AA,
138141 AssumptionCache *AC, DominatorTree *DT, TargetLibraryInfo *TLI)
139- : Mod(Mod), TT(Triple::normalize(Mod->getTargetTriple ())),
140- DL(DL), AA(AA), AC(AC), DT(DT), TLI(TLI),
141- MessagesStr(Messages) {}
142+ : Mod(Mod), TT(Triple::normalize(Mod->getTargetTriple ())), DL(DL), AA(AA),
143+ AC(AC), DT(DT), TLI(TLI), MessagesStr(Messages) {}
142144
143145 void WriteValues (ArrayRef<const Value *> Vs) {
144146 for (const Value *V : Vs) {
@@ -404,8 +406,9 @@ void Lint::visitMemoryReference(Instruction &I, const MemoryLocation &Loc,
404406
405407 if (Flags & MemRef::Write) {
406408 if (TT.isAMDGPU ())
407- Check (!AMDGPU::isConstantAddressSpace (UnderlyingObject->getType ()->getPointerAddressSpace ()),
408- " Undefined behavior: Write to const memory" , &I);
409+ Check (!AMDGPU::isConstantAddressSpace (
410+ UnderlyingObject->getType ()->getPointerAddressSpace ()),
411+ " Undefined behavior: Write to memory in const addrspace" , &I);
409412
410413 if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(UnderlyingObject))
411414 Check (!GV->isConstant (), " Undefined behavior: Write to read-only memory" ,
@@ -486,6 +489,16 @@ void Lint::visitStoreInst(StoreInst &I) {
486489 I.getOperand (0 )->getType (), MemRef::Write);
487490}
488491
492+ void Lint::visitAtomicCmpXchgInst (AtomicCmpXchgInst &I) {
493+ visitMemoryReference (I, MemoryLocation::get (&I), I.getAlign (),
494+ I.getOperand (0 )->getType (), MemRef::Write);
495+ }
496+
497+ void Lint::visitAtomicRMWInst (AtomicRMWInst &I) {
498+ visitMemoryReference (I, MemoryLocation::get (&I), I.getAlign (),
499+ I.getOperand (0 )->getType (), MemRef::Write);
500+ }
501+
489502void Lint::visitXor (BinaryOperator &I) {
490503 Check (!isa<UndefValue>(I.getOperand (0 )) || !isa<UndefValue>(I.getOperand (1 )),
491504 " Undefined result: xor(undef, undef)" , &I);
0 commit comments