HomePhabricator

[NewPM][TSan] Reiterate the TSan port

Description

[NewPM][TSan] Reiterate the TSan port

Summary:
Second iteration of D56433 which got reverted in rL350719. The problem
in the previous version was that we dropped the thunk calling the tsan init
function. The new version keeps the thunk which should appease dyld, but is not
actually OK wrt. the current semantics of function passes. Hence, add a
helper to insert the functions only on the first time. The helper
allows hooking into the insertion to be able to append them to the
global ctors list.

Reviewers: chandlerc, vitalybuka, fedor.sergeev, leonardchan

Subscribers: hiraditya, bollu, llvm-commits

Differential Revision: https://reviews.llvm.org/D56538

Details

Committed
pfaffeJan 16 2019, 1:28 AM
Differential Revision
D56538: [NewPM][TSan] Reiterate the TSan port
Parents
rL351313: [lldb] - Fix crash when listing the history with the key up.
Branches
Unknown
Tags
Unknown

Event Timeline

delcypher added inline comments.
/llvm/trunk/include/llvm/Transforms/Instrumentation/ThreadSanitizer.h
28

Looks like the end of this sentence is missing.

/llvm/trunk/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
295

Perhaps we should add an assert here (after getOrCreateSanitizerCtorAndInitFunctions) to check that TsanCtorFunction is in the list of global constructors?

/llvm/trunk/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
2

I'm not familiar with the new pass manager. Presumably this new RUN: line runs the pass through the new pass manager?

delcypher added inline comments.Jan 16 2019, 4:04 AM
/llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp
188

Why is this check written with this fall through? If the Ctor that we find has the wrong number of args or doesn't have the right return type we'll fall through and try to create the constructor any way which should fail as the function (with wrong type) already exists. Perhaps we should try to fail earlier. I don't think the fall through should ever happen so maybe this should be LLVM_UNREACHABLE or perhaps return std::make_pair(nullptr, nullptr)?