[llvm-dev] How does sanitizers in compiler-rt work?

Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 16 14:48:40 PDT 2017

> On Jun 16, 2017, at 4:11 AM, Dipanjan Das via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Can anybody give me any pointer on how compiler-rt, especially the sanitizers work? Do they operate on IR as any other LLVM pass? Or are they integral part of the frontend itself? I couldn't spot any documentation on the internals of compiler-rt project? What happens (sequence of actions) when I pass -fsanitizer=dataflow to clang?

Passing -fsanitize=dataflow tells clang to insert the dataflow sanitizer's instrumentation pass into the normal compilation pipeline. The instrumentation occurs at the LLVM IR level. The pass may insert calls into runtime functions which are provided by compiler-rt. Therefore, in order to link a program compiled with -fsanitize=dataflow, the appropriate runtime library from compiler-rt is required.

> Precisely, I intend to alter the behaviour of DFSan to suit my need.

What is your need, exactly?

> Therefore, I need to know how it gets integrated in the tool-chain. Initially, my idea was to insert the dfsan_set_label() calls to the IR and pass it to DFSan. However, I am not sure if it's designed to run on the source only, not on IR.

You should take a look at lib/Transforms/Instrumentation/DataFlowSanitizer.cpp. There doesn't appear to be much done at the source level.


> -- 
> Thanks & Regards,
> Dipanjan
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170616/9c794095/attachment-0001.html>

More information about the llvm-dev mailing list