Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ static bool isVtableAccess(Instruction *I) {
// instrumentation. The user has no way of suppressing them.
static bool shouldInstrumentReadWriteFromAddress(const Module *M, Value *Addr) {
// Peel off GEPs and BitCasts.
Addr = Addr->stripInBoundsOffsets();
// Note: This also peels AddrspaceCasts, so this should not be used when
// checking the address space below.
Value *PeeledAddr = Addr->stripInBoundsOffsets();

if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Addr)) {
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(PeeledAddr)) {
if (GV->hasSection()) {
StringRef SectionName = GV->getSection();
// Check if the global is in the PGO counters section.
Expand All @@ -373,11 +375,9 @@ static bool shouldInstrumentReadWriteFromAddress(const Module *M, Value *Addr) {

// Do not instrument accesses from different address spaces; we cannot deal
// with them.
if (Addr) {
Type *PtrTy = cast<PointerType>(Addr->getType()->getScalarType());
if (PtrTy->getPointerAddressSpace() != 0)
return false;
}
Type *PtrTy = cast<PointerType>(Addr->getType()->getScalarType());
if (PtrTy->getPointerAddressSpace() != 0)
return false;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; RUN: opt < %s -passes='tsan' -S | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"

define i32 @read_4_bytes(ptr %a) sanitize_thread {
entry:
%b = addrspacecast ptr %a to ptr addrspace(1)
%tmp1 = load volatile i32, ptr addrspace(1) %b, align 4
ret i32 %tmp1
}

; CHECK-NOT: call void @__tsan_read