[llvm-dev] Using TSAN along with custom llvm IR pass

Dmitry Vyukov via llvm-dev
2017-06-27T16:00:25Z

On Tue, Jun 27, 2017 at 4:18 PM, Nischai Vinesh
<nischai.vinesh at gmail.com> wrote:
> Hello,
>
> I have written a custom pass to do some tasks and I want to run this pass
on
> a source code file along with TSAN instrumentation.
>
> Steps I followed:
> 1. I compiled the code file with -fsanitize=thread and -emit-llvm to get
the
> byte code of the file
> 2.  Used opt to run my custom pass on the TSAN instrumented .bc file
> 3. Run the final .bc file using lli with proper inputs
>
> This gives me a "LLVM ERROR: Program used external function
'__tsan_init'
> which could not be resolved!"
>
>
> I tried to instrument TSAN on a later step, as follows:
> 1. Used -emit-llvm to get the .bc file
> 2. Used opt to run my custom pass on the .bc file
> 3. Used llc to compile the program to native assembly
> 4. Used gcc/clang along with -fsanitize=thread to assemble it into a
program
>
> This does not throws any tsan warnings!  (There are some data race errors
> intentionally coded in the program to test this)
>
> Is there any ways to do this, instrumenting the source code with tsan and
> use a custom pass to do some other tasks on the same binary?
>
>
> Thank you

+llvm-dev mailing list