@@ -439,6 +439,11 @@ void ThreadSanitizerOnSpirv::instrumentGlobalVariables() {
439
439
StructType *StructTy = StructType::get (IntptrTy, IntptrTy);
440
440
441
441
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
+
442
447
if (isUnsupportedDeviceGlobal (G)) {
443
448
for (auto *User : G.users ())
444
449
if (auto *Inst = dyn_cast<Instruction>(User))
@@ -916,7 +921,9 @@ bool ThreadSanitizer::sanitizeFunction(Function &F,
916
921
917
922
// Instrument atomic memory accesses in any case (they can be used to
918
923
// implement synchronization).
919
- if (ClInstrumentAtomics)
924
+ // TODO: Disable atomics check for spirv target temporarily, will support it
925
+ // later.
926
+ if (!Spirv && ClInstrumentAtomics)
920
927
for (auto *Inst : AtomicAccesses) {
921
928
Res |= instrumentAtomic (Inst, DL);
922
929
}
@@ -980,7 +987,8 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
980
987
int Idx = getMemoryAccessFuncIndex (OrigTy, Addr, DL);
981
988
if (Idx < 0 )
982
989
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 )) {
984
992
LLVM_DEBUG (dbgs () << " VPTR : " << *II.Inst << " \n " );
985
993
Value *StoredValue = cast<StoreInst>(II.Inst )->getValueOperand ();
986
994
// StoredValue may be a vector type if we are storing several vptrs at once.
@@ -996,7 +1004,7 @@ bool ThreadSanitizer::instrumentLoadOrStore(const InstructionInfo &II,
996
1004
NumInstrumentedVtableWrites++;
997
1005
return true ;
998
1006
}
999
- if (!IsWrite && isVtableAccess (II.Inst )) {
1007
+ if (!Spirv && ! IsWrite && isVtableAccess (II.Inst )) {
1000
1008
IRB.CreateCall (TsanVptrLoad, Addr);
1001
1009
NumInstrumentedVtableReads++;
1002
1010
return true ;
0 commit comments