Tread TSan LLVM flags to driver: account for external flag values in TSan.
Diff Detail
- Build Status
Buildable 1146 Build 1146: arc lint + arc unit
Event Timeline
Could/should these be function attributes rather than pass arguments?
The use that we have for these flags is related to ignoring atomics in a huge source file, applying attributes to all functions in that file is impractical.
We have similar compiler flags for other sanitizers as well.
We could add attributes along with flags, but we don't have any uses for that at the moment.
lib/Transforms/Instrumentation/ThreadSanitizer.cpp | ||
---|---|---|
85–96 | Do we need default parameter values here? I would expect that not. | |
114 | I would make them const as they are initialized only in ctor and are not meant to change. |
The use case I have in mind is to make the sanitizers work better with LTO by running the sanitizer passes at link time. That would require that we preserve the flag settings in bitcode. Granted this isn't how things work right now, but it may be worth making it easier to get there given that these are new flags.
Attribute is definitely the right long term solution, but it would be more efficient to move all sanitizer options to attributes in bulk. It also adds overhead (possibly tiny) compared to the pass argument approach, so it only makes sense to do if we plan to move instrumentation passes to the link stage right away. I don't think we want to work on that right now.
So the question is, do we want this temporary implementation, or are we fine with -mllvm flags? Seeing as the code is already written, I'd prefer to land this change now.
There are a couple of intermediate steps towards making the flags you're introducing in D26461 work correctly with LTO:
- teach the clang driver to understand the flags
- thread the flags down to the pass via attributes
What I would suggest is that we could initially take step 1 by having the driver translate -fsanitize-thread-* flags to -mllvm flags for the frontend, and take step 2 in a separate change.
lib/Transforms/Instrumentation/ThreadSanitizer.cpp | ||
---|---|---|
85–96 | Yes, we do. FunctionPass is expected to have a zero arg ctor (see PassSupport.h, callDefaultCtor). |
Do we need default parameter values here? I would expect that not.