diff options
author | Kostya Serebryany <kcc@google.com> | 2013-12-05 15:03:02 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-12-05 15:03:02 +0000 |
commit | 64abf5b441a18c6678853a648ccb59e5a7a39296 (patch) | |
tree | f80fdcef627199589da6df012ae51e4c9ef3b52b | |
parent | 7add5421a686877e0aa87616b92b1f5a85c6feee (diff) | |
download | llvm-64abf5b441a18c6678853a648ccb59e5a7a39296.tar.gz llvm-64abf5b441a18c6678853a648ccb59e5a7a39296.tar.bz2 llvm-64abf5b441a18c6678853a648ccb59e5a7a39296.tar.xz |
[tsan] fix PR18146: sometimes a variable written into vptr could have an integer type (after other optimizations)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196507 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Instrumentation/ThreadSanitizer.cpp | 4 | ||||
-rw-r--r-- | test/Instrumentation/ThreadSanitizer/vptr_update.ll | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp index baec1534e0..5c18817820 100644 --- a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -408,10 +408,12 @@ bool ThreadSanitizer::instrumentLoadOrStore(Instruction *I) { 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; } diff --git a/test/Instrumentation/ThreadSanitizer/vptr_update.ll b/test/Instrumentation/ThreadSanitizer/vptr_update.ll index 4665004054..83d28b6ee2 100644 --- a/test/Instrumentation/ThreadSanitizer/vptr_update.ll +++ b/test/Instrumentation/ThreadSanitizer/vptr_update.ll @@ -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() |