[tsan] fix compile-time falilure found while building Chromium with tsan (tsan issue #3). A unit test will follow separately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159736 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kostya Serebryany 2012-07-05 09:07:31 +00:00
parent 7a7a6db6d7
commit 4a002ab9c3

View File

@ -319,7 +319,12 @@ bool ThreadSanitizer::instrumentLoadOrStore(Instruction *I) {
if (Idx < 0)
return false;
if (IsWrite && isVtableAccess(I)) {
DEBUG(dbgs() << " VPTR : " << *I << "\n");
Value *StoredValue = cast<StoreInst>(I)->getValueOperand();
// StoredValue does not necessary have a pointer type.
if (isa<IntegerType>(StoredValue->getType()))
StoredValue = IRB.CreateIntToPtr(StoredValue, IRB.getInt8PtrTy());
// Call TsanVptrUpdate.
IRB.CreateCall2(TsanVptrUpdate,
IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()),
IRB.CreatePointerCast(StoredValue, IRB.getInt8PtrTy()));