[llvm] r196507 - [tsan] fix PR18146: sometimes a variable written into vptr could have an integer type (after other optimizations)
Kostya Serebryany
kcc at google.com
Thu Dec 5 07:03:02 PST 2013
Author: kcc
Date: Thu Dec 5 09:03:02 2013
New Revision: 196507
URL: http://llvm.org/viewvc/llvm-project?rev=196507&view=rev
Log:
[tsan] fix PR18146: sometimes a variable written into vptr could have an integer type (after other optimizations)
Modified:
llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/trunk/test/Instrumentation/ThreadSanitizer/vptr_update.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp?rev=196507&r1=196506&r2=196507&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp Thu Dec 5 09:03:02 2013
@@ -408,10 +408,12 @@ bool ThreadSanitizer::instrumentLoadOrSt
if (isa<VectorType>(StoredValue->getType()))
StoredValue = IRB.CreateExtractElement(
StoredValue, ConstantInt::get(IRB.getInt32Ty(), 0));
+ if (StoredValue->getType()->isIntegerTy())
+ StoredValue = IRB.CreateIntToPtr(StoredValue, IRB.getInt8PtrTy());
// Call TsanVptrUpdate.
IRB.CreateCall2(TsanVptrUpdate,
IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()),
- IRB.CreateBitCast(StoredValue, IRB.getInt8PtrTy()));
+ IRB.CreatePointerCast(StoredValue, IRB.getInt8PtrTy()));
NumInstrumentedVtableWrites++;
return true;
}
Modified: llvm/trunk/test/Instrumentation/ThreadSanitizer/vptr_update.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/ThreadSanitizer/vptr_update.ll?rev=196507&r1=196506&r2=196507&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/ThreadSanitizer/vptr_update.ll (original)
+++ llvm/trunk/test/Instrumentation/ThreadSanitizer/vptr_update.ll Thu Dec 5 09:03:02 2013
@@ -11,6 +11,16 @@ entry:
ret void
}
+define void @FooInt(i64* nocapture %a, i64 %b) nounwind uwtable sanitize_thread {
+entry:
+; CHECK-LABEL: @FooInt
+; CHECK: call void @__tsan_vptr_update
+; CHECK: ret void
+ store i64 %b, i64* %a, align 8, !tbaa !0
+ ret void
+}
+
+
declare i32 @Func1()
declare i32 @Func2()
More information about the llvm-commits
mailing list