From 8614397110595e267b7e4e1f558bfce619e60c02 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 25 Apr 2017 15:37:56 -0400 Subject: compile time improvement - move overflow math safety to fns move some boilerplate code having to do with overflow math safety to functions. Again the timing difference is not much: Before: ./build size: 1.3 MB hello.zig size: 308 KB full test: 1m33.588s debug test: 20.303s hello.zig timing: Name Start End Duration Percent Initialize 0.0000 0.0000 0.0000 0.0002 Semantic Analysis 0.0000 0.0425 0.0425 0.2202 Code Generation 0.0425 0.0675 0.0250 0.1293 LLVM Emit Object 0.0675 0.1789 0.1114 0.5773 Build Dependencies 0.1789 0.1913 0.0124 0.0640 LLVM Link 0.1913 0.1931 0.0018 0.0091 Generate .h 0.1931 0.1931 0.0000 0.0000 Total 0.0000 0.1931 0.1931 1.0000 After: ./build size: 1.3 MB hello.zig size: 301 KB full test: 1m31.253s debug test: 19.607s hello.zig timing: Name Start End Duration Percent Initialize 0.0000 0.0000 0.0000 0.0002 Semantic Analysis 0.0000 0.0431 0.0431 0.2262 Code Generation 0.0431 0.0660 0.0229 0.1201 LLVM Emit Object 0.0660 0.1765 0.1105 0.5795 Build Dependencies 0.1765 0.1890 0.0125 0.0655 LLVM Link 0.1890 0.1906 0.0016 0.0086 Generate .h 0.1906 0.1906 0.0000 0.0000 Total 0.0000 0.1906 0.1906 1.0000 --- src/analyze.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index ebbb3e0689..a190ee88b7 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -4141,6 +4141,10 @@ uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) { return ((uint32_t)(x.data.overflow_arithmetic.bit_count) * 87135777) + ((uint32_t)(x.data.overflow_arithmetic.add_sub_mul) * 31640542) + ((uint32_t)(x.data.overflow_arithmetic.is_signed) ? 1062315172 : 314955820); + case ZigLLVMFnIdOverflowArithmeticPanic: + return ((uint32_t)(x.data.overflow_arithmetic.bit_count) * 3329604261) + + ((uint32_t)(x.data.overflow_arithmetic.add_sub_mul) * 966805797) + + ((uint32_t)(x.data.overflow_arithmetic.is_signed) ? 3679835291 : 1187552903); } zig_unreachable(); } @@ -4154,6 +4158,7 @@ bool zig_llvm_fn_key_eql(ZigLLVMFnKey a, ZigLLVMFnKey b) { case ZigLLVMFnIdClz: return a.data.clz.bit_count == b.data.clz.bit_count; case ZigLLVMFnIdOverflowArithmetic: + case ZigLLVMFnIdOverflowArithmeticPanic: return (a.data.overflow_arithmetic.bit_count == b.data.overflow_arithmetic.bit_count) && (a.data.overflow_arithmetic.add_sub_mul == b.data.overflow_arithmetic.add_sub_mul) && (a.data.overflow_arithmetic.is_signed == b.data.overflow_arithmetic.is_signed); -- cgit v1.2.3