Skip to content
/ zig Public
forked from ziglang/zig

Commit

Permalink
llvm: Disable FastISel on MIPS as a workaround for ziglang#21215.
Browse files Browse the repository at this point in the history
Until llvm/llvm-project#106231 trickles down.
  • Loading branch information
alexrp committed Aug 28, 2024
1 parent 7d9edff commit e585103
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/codegen/llvm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,8 @@ pub const Object = struct {
.tsan = options.sanitize_thread,
.sancov = options.fuzz,
.lto = options.lto,
// https://github.com/ziglang/zig/issues/21215
.allow_fast_isel = !comp.root_mod.resolved_target.result.cpu.arch.isMIPS(),
.asm_filename = null,
.bin_filename = options.bin_path,
.llvm_ir_filename = options.post_ir_path,
Expand Down
1 change: 1 addition & 0 deletions src/codegen/llvm/bindings.zig
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub const TargetMachine = opaque {
tsan: bool,
sancov: bool,
lto: bool,
allow_fast_isel: bool,
asm_filename: ?[*:0]const u8,
bin_filename: ?[*:0]const u8,
llvm_ir_filename: ?[*:0]const u8,
Expand Down
7 changes: 6 additions & 1 deletion src/zig_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi
options.bin_filename? options.bin_filename : options.asm_filename);

TargetMachine &target_machine = *reinterpret_cast<TargetMachine*>(targ_machine_ref);
target_machine.setO0WantsFastISel(true);

Module &llvm_module = *unwrap(module_ref);

Expand Down Expand Up @@ -369,6 +368,12 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi
}
}

if (options.allow_fast_isel) {
target_machine.setO0WantsFastISel(true);
} else {
target_machine.setFastISel(false);
}

// Optimization phase
module_pm.run(llvm_module, module_am);

Expand Down
1 change: 1 addition & 0 deletions src/zig_llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct ZigLLVMEmitOptions {
bool tsan;
bool sancov;
bool lto;
bool allow_fast_isel;
const char *asm_filename;
const char *bin_filename;
const char *llvm_ir_filename;
Expand Down

0 comments on commit e585103

Please sign in to comment.