| author | |
| committer | |
| log | 4d8c5dd4be7a84c5f01f8910c44c5a1e23740b77 |
| tree | f88b867af7671eb20b942a04cce928dc57352872 |
| parent | a4b134746f61a2f07ea5450c0504f51cba8f6be3 |
3 files changed, 14 insertions(+), 4 deletions(-)
src/stage1/codegen.cpp+2-2| ... | ... | @@ -8436,7 +8436,7 @@ static void zig_llvm_emit_output(CodeGen *g) { |
| 8436 | 8436 | // pipeline multiple times if this is requested. |
| 8437 | 8437 | if (asm_filename != nullptr && bin_filename != nullptr) { |
| 8438 | 8438 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, &err_msg, g->build_mode == BuildModeDebug, |
| 8439 | is_small, g->enable_time_report, nullptr, bin_filename, llvm_ir_filename)) | |
| 8439 | is_small, g->enable_time_report, g->tsan_enabled, nullptr, bin_filename, llvm_ir_filename)) | |
| 8440 | 8440 | { |
| 8441 | 8441 | fprintf(stderr, "LLVM failed to emit file: %s\n", err_msg); |
| 8442 | 8442 | exit(1); |
| ... | ... | @@ -8446,7 +8446,7 @@ static void zig_llvm_emit_output(CodeGen *g) { |
| 8446 | 8446 | } |
| 8447 | 8447 | |
| 8448 | 8448 | if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, &err_msg, g->build_mode == BuildModeDebug, |
| 8449 | is_small, g->enable_time_report, asm_filename, bin_filename, llvm_ir_filename)) | |
| 8449 | is_small, g->enable_time_report, g->tsan_enabled, asm_filename, bin_filename, llvm_ir_filename)) | |
| 8450 | 8450 | { |
| 8451 | 8451 | fprintf(stderr, "LLVM failed to emit file: %s\n", err_msg); |
| 8452 | 8452 | exit(1); |
src/zig_llvm.cpp+11-1| ... | ... | @@ -50,6 +50,7 @@ |
| 50 | 50 | #include <llvm/Transforms/IPO.h> |
| 51 | 51 | #include <llvm/Transforms/IPO/AlwaysInliner.h> |
| 52 | 52 | #include <llvm/Transforms/IPO/PassManagerBuilder.h> |
| 53 | #include <llvm/Transforms/Instrumentation/ThreadSanitizer.h> | |
| 53 | 54 | #include <llvm/Transforms/Scalar.h> |
| 54 | 55 | #include <llvm/Transforms/Utils.h> |
| 55 | 56 | |
| ... | ... | @@ -93,6 +94,10 @@ static void addDiscriminatorsPass(const PassManagerBuilder &Builder, legacy::Pas |
| 93 | 94 | PM.add(createAddDiscriminatorsPass()); |
| 94 | 95 | } |
| 95 | 96 | |
| 97 | static void addThreadSanitizerPass(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { | |
| 98 | PM.add(createThreadSanitizerLegacyPassPass()); | |
| 99 | } | |
| 100 | ||
| 96 | 101 | #ifndef NDEBUG |
| 97 | 102 | static const bool assertions_on = true; |
| 98 | 103 | #else |
| ... | ... | @@ -179,7 +184,7 @@ unsigned ZigLLVMDataLayoutGetProgramAddressSpace(LLVMTargetDataRef TD) { |
| 179 | 184 | |
| 180 | 185 | bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, |
| 181 | 186 | char **error_message, bool is_debug, |
| 182 | bool is_small, bool time_report, | |
| 187 | bool is_small, bool time_report, bool tsan, | |
| 183 | 188 | const char *asm_filename, const char *bin_filename, const char *llvm_ir_filename) |
| 184 | 189 | { |
| 185 | 190 | TimePassesIsEnabled = time_report; |
| ... | ... | @@ -245,6 +250,11 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM |
| 245 | 250 | PMBuilder->Inliner = createFunctionInliningPass(PMBuilder->OptLevel, PMBuilder->SizeLevel, false); |
| 246 | 251 | } |
| 247 | 252 | |
| 253 | if (tsan) { | |
| 254 | PMBuilder->addExtension(PassManagerBuilder::EP_OptimizerLast, addThreadSanitizerPass); | |
| 255 | PMBuilder->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, addThreadSanitizerPass); | |
| 256 | } | |
| 257 | ||
| 248 | 258 | // Set up the per-function pass manager. |
| 249 | 259 | legacy::FunctionPassManager FPM = legacy::FunctionPassManager(module); |
| 250 | 260 | auto tliwp = new(std::nothrow) TargetLibraryInfoWrapperPass(tlii); |
src/zig_llvm.h+1-1| ... | ... | @@ -48,7 +48,7 @@ ZIG_EXTERN_C char *ZigLLVMGetNativeFeatures(void); |
| 48 | 48 | |
| 49 | 49 | ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, |
| 50 | 50 | char **error_message, bool is_debug, |
| 51 | bool is_small, bool time_report, | |
| 51 | bool is_small, bool time_report, bool tsan, | |
| 52 | 52 | const char *asm_filename, const char *bin_filename, const char *llvm_ir_filename); |
| 53 | 53 | |
| 54 | 54 |