[llvm-dev] Using TSAN along with custom llvm IR pass
Nischai Vinesh via llvm-dev
llvm-dev at lists.llvm.org
Sun Jul 9 06:50:55 PDT 2017
I tried that as well but there are no tsan warnings thrown at run time,
even though there are data race error!
The steps I followed:
1. Generate bitcode using 'clang -emit-llvm' command
2. Using the 'opt -load ..' command, I instrumented the bitcode file with
my custom pass
3. Using the command 'opt -tsan ..', instrumented the output bitcode file
from step 2
4. Using the llvm backend compiler, 'llc', compiled the program to native
5. The output from step 4 is compiled again with 'clang -fsanitize=thread'
(linking tsan here) for the final object file.
Executing this final output file works fine, except that it doesn't throws
any TSAN warnings!
In between, lli command is used to invoke the LLVM Interpreter.
On Wednesday, June 28, 2017 at 2:12:11 PM UTC+2, Dmitry Vyukov wrote:
> On Tue, Jun 27, 2017 at 6:00 PM, Dmitry Vyukov <dvy... at google.com
> > On Tue, Jun 27, 2017 at 4:18 PM, Nischai Vinesh
> >> 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
> >> which could not be resolved!"
> I don't know what is lli, but from the error message it seems that the
> problem is that you don't link in tsan runtime (tsan runtime provides
> __tsan_init function).
> I think you need to compile you instrumented file into object file
> first (.o), and then link it with clang -fsanitize=thread (which will
> link in runtime).
> >> 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
> >> This does not throws any tsan warnings! (There are some data race
> >> intentionally coded in the program to test this)
> >> Is there any ways to do this, instrumenting the source code with tsan
> >> use a custom pass to do some other tasks on the same binary?
> >> Thank you
> > +llvm-dev mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev