diff options
| author | gingerBill <bill@gingerbill.org> | 2023-08-10 14:35:09 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-08-10 14:35:09 +0100 |
| commit | 589820639c38979f4c801e8edcbb62c21ca15099 (patch) | |
| tree | 8775a9dd2f58991bb6f408e7bdd80b7504e40bf7 /src/llvm_backend_opt.cpp | |
| parent | 49b24471133cfbd2664337d99a3259f0b2f4ad45 (diff) | |
Correct `lb_run_function_pass_manager` behaviour
Diffstat (limited to 'src/llvm_backend_opt.cpp')
| -rw-r--r-- | src/llvm_backend_opt.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/llvm_backend_opt.cpp b/src/llvm_backend_opt.cpp index 54e667a0b..068546e9d 100644 --- a/src/llvm_backend_opt.cpp +++ b/src/llvm_backend_opt.cpp @@ -374,12 +374,24 @@ gb_internal void lb_run_function_pass_manager(LLVMPassManagerRef fpm, lbProcedur if (p == nullptr) { return; } - LLVMRunFunctionPassManager(fpm, p->value); // NOTE(bill): LLVMAddDCEPass doesn't seem to be exported in the official DLL's for LLVM // which means we cannot rely upon it // This is also useful for read the .ll for debug purposes because a lot of instructions // are not removed lb_run_remove_dead_instruction_pass(p); + + switch (pass_manager_kind) { + case lbFunctionPassManager_none: + return; + case lbFunctionPassManager_default: + case lbFunctionPassManager_default_without_memcpy: + if (build_context.optimization_level < 0) { + return; + } + break; + } + + LLVMRunFunctionPassManager(fpm, p->value); } gb_internal void llvm_delete_function(LLVMValueRef func) { |