| author | |
| committer | |
| log | a44085dc2ab81877fc71fb50e846454c2694a14c |
| tree | e3ffb828f5933a7a1df32c7e06f2c90871d59c8f |
| parent | 93bdd04e8880f0ae2ad73b5922d499ec8500a82c |
| signature |
8 files changed, 35 insertions(+), 0 deletions(-)
src/Compilation.zig+2| ... | ... | @@ -968,6 +968,7 @@ pub const InitOptions = struct { |
| 968 | 968 | linker_print_gc_sections: bool = false, |
| 969 | 969 | linker_print_icf_sections: bool = false, |
| 970 | 970 | linker_print_map: bool = false, |
| 971 | linker_opt_bisect_limit: i32 = -1, | |
| 971 | 972 | each_lib_rpath: ?bool = null, |
| 972 | 973 | build_id: ?bool = null, |
| 973 | 974 | disable_c_depfile: bool = false, |
| ... | ... | @@ -1826,6 +1827,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1826 | 1827 | .print_gc_sections = options.linker_print_gc_sections, |
| 1827 | 1828 | .print_icf_sections = options.linker_print_icf_sections, |
| 1828 | 1829 | .print_map = options.linker_print_map, |
| 1830 | .opt_bisect_limit = options.linker_opt_bisect_limit, | |
| 1829 | 1831 | .z_nodelete = options.linker_z_nodelete, |
| 1830 | 1832 | .z_notext = options.linker_z_notext, |
| 1831 | 1833 | .z_defs = options.linker_z_defs, |
src/codegen/llvm.zig+4| ... | ... | @@ -520,6 +520,10 @@ pub const Object = struct { |
| 520 | 520 | if (options.pie) llvm_module.setModulePIELevel(); |
| 521 | 521 | if (code_model != .Default) llvm_module.setModuleCodeModel(code_model); |
| 522 | 522 | |
| 523 | if (options.opt_bisect_limit >= 0) { | |
| 524 | context.setOptBisectLimit(std.math.lossyCast(c_int, options.opt_bisect_limit)); | |
| 525 | } | |
| 526 | ||
| 523 | 527 | return Object{ |
| 524 | 528 | .gpa = gpa, |
| 525 | 529 | .module = options.module.?, |
src/codegen/llvm/bindings.zig+3| ... | ... | @@ -85,6 +85,9 @@ pub const Context = opaque { |
| 85 | 85 | |
| 86 | 86 | pub const createBuilder = LLVMCreateBuilderInContext; |
| 87 | 87 | extern fn LLVMCreateBuilderInContext(C: *Context) *Builder; |
| 88 | ||
| 89 | pub const setOptBisectLimit = ZigLLVMSetOptBisectLimit; | |
| 90 | extern fn ZigLLVMSetOptBisectLimit(C: *Context, limit: c_int) void; | |
| 88 | 91 | }; |
| 89 | 92 | |
| 90 | 93 | pub const Value = opaque { |
src/link.zig+1| ... | ... | @@ -169,6 +169,7 @@ pub const Options = struct { |
| 169 | 169 | print_gc_sections: bool, |
| 170 | 170 | print_icf_sections: bool, |
| 171 | 171 | print_map: bool, |
| 172 | opt_bisect_limit: i32, | |
| 172 | 173 | |
| 173 | 174 | objects: []Compilation.LinkObject, |
| 174 | 175 | framework_dirs: []const []const u8, |
src/main.zig+5| ... | ... | @@ -536,6 +536,7 @@ const usage_build_generic = |
| 536 | 536 | \\ --test-runner [path] Specify a custom test runner |
| 537 | 537 | \\ |
| 538 | 538 | \\Debug Options (Zig Compiler Development): |
| 539 | \\ -fopt-bisect-limit [limit] Only run [limit] first LLVM optimization passes | |
| 539 | 540 | \\ -ftime-report Print timing diagnostics |
| 540 | 541 | \\ -fstack-report Print stack size diagnostics |
| 541 | 542 | \\ --verbose-link Display linker invocations |
| ... | ... | @@ -729,6 +730,7 @@ fn buildOutputType( |
| 729 | 730 | var linker_print_gc_sections: bool = false; |
| 730 | 731 | var linker_print_icf_sections: bool = false; |
| 731 | 732 | var linker_print_map: bool = false; |
| 733 | var linker_opt_bisect_limit: i32 = -1; | |
| 732 | 734 | var linker_z_nocopyreloc = false; |
| 733 | 735 | var linker_z_nodelete = false; |
| 734 | 736 | var linker_z_notext = false; |
| ... | ... | @@ -1285,6 +1287,8 @@ fn buildOutputType( |
| 1285 | 1287 | no_builtin = false; |
| 1286 | 1288 | } else if (mem.eql(u8, arg, "-fno-builtin")) { |
| 1287 | 1289 | no_builtin = true; |
| 1290 | } else if (mem.startsWith(u8, arg, "-fopt-bisect-limit=")) { | |
| 1291 | linker_opt_bisect_limit = std.math.lossyCast(i32, parseIntSuffix(arg, "-fopt-bisect-limit=".len)); | |
| 1288 | 1292 | } else if (mem.eql(u8, arg, "--eh-frame-hdr")) { |
| 1289 | 1293 | link_eh_frame_hdr = true; |
| 1290 | 1294 | } else if (mem.eql(u8, arg, "--emit-relocs")) { |
| ... | ... | @@ -2996,6 +3000,7 @@ fn buildOutputType( |
| 2996 | 3000 | .linker_print_gc_sections = linker_print_gc_sections, |
| 2997 | 3001 | .linker_print_icf_sections = linker_print_icf_sections, |
| 2998 | 3002 | .linker_print_map = linker_print_map, |
| 3003 | .linker_opt_bisect_limit = linker_opt_bisect_limit, | |
| 2999 | 3004 | .linker_global_base = linker_global_base, |
| 3000 | 3005 | .linker_export_symbol_names = linker_export_symbol_names.items, |
| 3001 | 3006 | .linker_z_nocopyreloc = linker_z_nocopyreloc, |
src/zig_llvm.cpp+13| ... | ... | @@ -31,6 +31,7 @@ |
| 31 | 31 | #include <llvm/IR/Instructions.h> |
| 32 | 32 | #include <llvm/IR/LegacyPassManager.h> |
| 33 | 33 | #include <llvm/IR/Module.h> |
| 34 | #include <llvm/IR/OptBisect.h> | |
| 34 | 35 | #include <llvm/IR/PassManager.h> |
| 35 | 36 | #include <llvm/IR/Verifier.h> |
| 36 | 37 | #include <llvm/InitializePasses.h> |
| ... | ... | @@ -412,6 +413,18 @@ ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref) { |
| 412 | 413 | return wrap(Type::getTokenTy(*unwrap(context_ref))); |
| 413 | 414 | } |
| 414 | 415 | |
| 416 | ||
| 417 | ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit) { | |
| 418 | // In LLVM15 we just have an OptBisect singleton we can edit. | |
| 419 | OptBisect& bisect = getOptBisector(); | |
| 420 | bisect.setLimit(limit); | |
| 421 | ||
| 422 | // In LLVM16 OptBisect will be wrapped in OptPassGate, and will need to be set per context. | |
| 423 | // static OptBisect _opt_bisector; | |
| 424 | // _opt_bisector.setLimit(limit); | |
| 425 | // unwrap(context_ref)->setOptPassGate(_opt_bisector); | |
| 426 | } | |
| 427 | ||
| 415 | 428 | LLVMValueRef ZigLLVMAddFunctionInAddressSpace(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy, unsigned AddressSpace) { |
| 416 | 429 | Function* func = Function::Create(unwrap<FunctionType>(FunctionTy), GlobalValue::ExternalLinkage, AddressSpace, Name, unwrap(M)); |
| 417 | 430 | return wrap(func); |
src/zig_llvm.h+2| ... | ... | @@ -67,6 +67,8 @@ ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, co |
| 67 | 67 | |
| 68 | 68 | ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref); |
| 69 | 69 | |
| 70 | ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit); | |
| 71 | ||
| 70 | 72 | ZIG_EXTERN_C LLVMValueRef ZigLLVMAddFunctionInAddressSpace(LLVMModuleRef M, const char *Name, |
| 71 | 73 | LLVMTypeRef FunctionTy, unsigned AddressSpace); |
| 72 | 74 |
tools/stage2_gdb_pretty_printers.py+5| ... | ... | @@ -2,8 +2,13 @@ |
| 2 | 2 | # put "source /path/to/stage2_gdb_pretty_printers.py" in ~/.gdbinit to load it automatically. |
| 3 | 3 | import re |
| 4 | 4 | import gdb.printing |
| 5 | ||
| 6 | import sys | |
| 7 | from pathlib import Path | |
| 8 | sys.path.insert(0, str(Path(__file__).parent)) | |
| 5 | 9 | import stage2_pretty_printers_common as common |
| 6 | 10 | |
| 11 | ||
| 7 | 12 | class TypePrinter: |
| 8 | 13 | def __init__(self, val): |
| 9 | 14 | self.val = val |