aboutsummaryrefslogtreecommitdiff
path: root/src/zig_llvm.cpp
diff options
context:
space:
mode:
authorMin-Yih Hsu <minyihh@uci.edu>2021-04-09 13:00:46 -0700
committerMin-Yih Hsu <minyihh@uci.edu>2021-04-09 16:51:35 -0700
commit52d871844c643f396a2bddee0753d24ff71ca3bb (patch)
tree05adee310cd34a85fd6ced7777d669e7442f6817 /src/zig_llvm.cpp
parent6b3eaa62e86d2652cf0b0802d704ab16d148c2ce (diff)
downloadzig-52d871844c643f396a2bddee0753d24ff71ca3bb.tar.gz
zig-52d871844c643f396a2bddee0753d24ff71ca3bb.zip
llvm new-pm: Build O0 pipeline in the correct way
Use `PassBuilder::buildO0DefaultPipeline` to build pipeline for -O0 in replacement of `PassBuilder::buildPerModuleDefaultPipeline`. This affects both normal and LTO settings. Two redundant Passes - which were added by accident - were also removed from LTO pipeline.
Diffstat (limited to 'src/zig_llvm.cpp')
-rw-r--r--src/zig_llvm.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp
index 0d60d7a4ac..7866537c64 100644
--- a/src/zig_llvm.cpp
+++ b/src/zig_llvm.cpp
@@ -277,15 +277,8 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
});
}
- // Passes for either debug or release build
- if (is_debug) {
- // NOTE: Always inliner will go away (in debug build)
- // when the self-hosted compiler becomes mature.
- pass_builder.registerPipelineStartEPCallback(
- [](ModulePassManager &module_pm, OptimizationLevel OL) {
- module_pm.addPass(AlwaysInlinerPass());
- });
- } else {
+ // Passes specific for release build
+ if (!is_debug) {
pass_builder.registerPipelineStartEPCallback(
[](ModulePassManager &module_pm, OptimizationLevel OL) {
module_pm.addPass(
@@ -312,10 +305,10 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
opt_level = OptimizationLevel::O3;
// Initialize the PassManager
- if (lto) {
+ if (opt_level == OptimizationLevel::O0) {
+ module_pm = pass_builder.buildO0DefaultPipeline(opt_level, lto);
+ } else if (lto) {
module_pm = pass_builder.buildLTOPreLinkDefaultPipeline(opt_level);
- module_pm.addPass(CanonicalizeAliasesPass());
- module_pm.addPass(NameAnonGlobalPass());
} else {
module_pm = pass_builder.buildPerModuleDefaultPipeline(opt_level);
}