Home | History | Annotate | Download | only in ThreadSanitizer
      1 ; RUN: opt < %s -tsan -S | FileCheck %s
      2 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
      3 target triple = "x86_64-apple-macosx10.11.0"
      4 
      5 ; Checks that we do not instrument loads and stores comming from custom address space.
      6 ; These result in crashing the compiler.
      7 ; int foo(int argc, const char * argv[]) {
      8 ;   void *__attribute__((address_space(256))) *gs_base = (((void * __attribute__((address_space(256))) *)0));
      9 ;   void *somevalue = gs_base[-1];
     10 ;   return somevalue;
     11 ; }
     12 
     13 define i32 @foo(i32 %argc, i8** %argv) sanitize_thread {
     14 entry:
     15   %retval = alloca i32, align 4
     16   %argc.addr = alloca i32, align 4
     17   %argv.addr = alloca i8**, align 8
     18   %gs_base = alloca i8* addrspace(256)*, align 8
     19   %somevalue = alloca i8*, align 8
     20   store i32 0, i32* %retval, align 4
     21   store i32 %argc, i32* %argc.addr, align 4
     22   store i8** %argv, i8*** %argv.addr, align 8
     23   store i8* addrspace(256)* null, i8* addrspace(256)** %gs_base, align 8
     24   %0 = load i8* addrspace(256)*, i8* addrspace(256)** %gs_base, align 8
     25   %arrayidx = getelementptr inbounds i8*, i8* addrspace(256)* %0, i64 -1
     26   %1 = load i8*, i8* addrspace(256)* %arrayidx, align 8
     27   store i8* %1, i8** %somevalue, align 8
     28   %2 = load i8*, i8** %somevalue, align 8
     29   %3 = ptrtoint i8* %2 to i32
     30   ret i32 %3
     31 }
     32 ; CHECK-NOT: call void @__tsan_read
     33 ; CHECK-NOT: addrspacecast
     34