@@ -439,6 +439,11 @@ void ThreadSanitizerOnSpirv::instrumentGlobalVariables() {
439439 StructType *StructTy = StructType::get (IntptrTy, IntptrTy);
440440
441441 for (auto &G : M.globals ()) {
442+ // DeviceSanitizers cannot handle nameless globals, therefore we set a name
443+ // for them so that we can handle them like regular globals.
444+ if (G.getName ().empty () && G.hasInternalLinkage ())
445+ G.setName (" nameless_global" );
446+
442447 if (isUnsupportedDeviceGlobal (G)) {
443448 for (auto *User : G.users ())
444449 if (auto *Inst = dyn_cast<Instruction>(User))
@@ -916,7 +921,9 @@ bool ThreadSanitizer::sanitizeFunction(Function &F,
916921
917922 // Instrument atomic memory accesses in any case (they can be used to
918923 // implement synchronization).
919- if (ClInstrumentAtomics)
924+ // TODO: Disable atomics check for spirv target temporarily, will support it
925+ // later.
926+ if (!Spirv && ClInstrumentAtomics)
920927 for (auto *Inst : AtomicAccesses) {
921928 Res |= instrumentAtomic (Inst, DL);
922929 }
@@ -980,7 +987,8 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
980987 int Idx = getMemoryAccessFuncIndex (OrigTy, Addr, DL);
981988 if (Idx < 0 )
982989 return false ;
983- if (IsWrite && isVtableAccess (II.Inst )) {
990+ // There is no race-free access scenario to vtable for spirv target.
991+ if (!Spirv && IsWrite && isVtableAccess (II.Inst )) {
984992 LLVM_DEBUG (dbgs () << " VPTR : " << *II.Inst << " \n " );
985993 Value *StoredValue = cast<StoreInst>(II.Inst )->getValueOperand ();
986994 // StoredValue may be a vector type if we are storing several vptrs at once.
@@ -996,7 +1004,7 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
9961004 NumInstrumentedVtableWrites++;
9971005 return true ;
9981006 }
999- if (!IsWrite && isVtableAccess (II.Inst )) {
1007+ if (!Spirv && ! IsWrite && isVtableAccess (II.Inst )) {
10001008 IRB.CreateCall (TsanVptrLoad, Addr);
10011009 NumInstrumentedVtableReads++;
10021010 return true ;
0 commit comments