aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-12-24 15:17:52 -0800
committerGitHub <noreply@github.com>2020-12-24 15:17:52 -0800
commit9f33984119ee698a9b344ad0df7b498b334e0f6e (patch)
tree9f6fbf983be6d98337ced72a79f3215062bb4e64 /src/stage1/codegen.cpp
parente18abab55aea4a5c3b347274e41de9fdc24e950c (diff)
parent6ab9268a9024fe8e9076f07cb207107d2cad0876 (diff)
downloadzig-9f33984119ee698a9b344ad0df7b498b334e0f6e.tar.gz
zig-9f33984119ee698a9b344ad0df7b498b334e0f6e.zip
Merge pull request #7520 from ziglang/tsan
add support for TSAN
Diffstat (limited to 'src/stage1/codegen.cpp')
-rw-r--r--src/stage1/codegen.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp
index c7f429ef49..738c4b7b0a 100644
--- a/src/stage1/codegen.cpp
+++ b/src/stage1/codegen.cpp
@@ -472,6 +472,10 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) {
ZigLLVMFunctionSetCallingConv(llvm_fn, get_llvm_cc(g, cc));
}
+ if (g->tsan_enabled) {
+ addLLVMFnAttr(llvm_fn, "sanitize_thread");
+ }
+
bool want_cold = fn->is_cold;
if (want_cold) {
ZigLLVMAddFunctionAttrCold(llvm_fn);
@@ -8432,7 +8436,7 @@ static void zig_llvm_emit_output(CodeGen *g) {
// pipeline multiple times if this is requested.
if (asm_filename != nullptr && bin_filename != nullptr) {
if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, &err_msg, g->build_mode == BuildModeDebug,
- is_small, g->enable_time_report, nullptr, bin_filename, llvm_ir_filename))
+ is_small, g->enable_time_report, g->tsan_enabled, nullptr, bin_filename, llvm_ir_filename))
{
fprintf(stderr, "LLVM failed to emit file: %s\n", err_msg);
exit(1);
@@ -8442,7 +8446,7 @@ static void zig_llvm_emit_output(CodeGen *g) {
}
if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, &err_msg, g->build_mode == BuildModeDebug,
- is_small, g->enable_time_report, asm_filename, bin_filename, llvm_ir_filename))
+ is_small, g->enable_time_report, g->tsan_enabled, asm_filename, bin_filename, llvm_ir_filename))
{
fprintf(stderr, "LLVM failed to emit file: %s\n", err_msg);
exit(1);