aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
AgeCommit message (Collapse)Author
2022-12-30fix generic function arg debug info referencing wrong parameterVeikka Tuominen
Closes #14123
2022-12-27llvm: add asserts and behavior tests for #14063Jacob Young
Closes #14063
2022-12-27llvm: cleanup code no longer needed with opaque pointersJacob Young
When using llvm opaque pointers, typed pointers and pointer bitcasts are no longer needed. This also avoids needing packed struct layouts that are nested inside pointers, letting us avoid computing struct layouts in Sema that could cause unnecessary dependency loops.
2022-12-26Sema: add error for recursive inline callVeikka Tuominen
Closes #12973
2022-12-20Merge pull request #14004 from Vexu/packed-struct-vectorVeikka Tuominen
llvm: handle vectors in packed structs
2022-12-19llvm: handle vectors in packed structsVeikka Tuominen
Closes #13201
2022-12-18codegen: fix taking the address of a zero-bit field in a zero-bit structJacob Young
Normally when we want a pointer to the end of a struct we just add 1 to the struct pointer. However, when it is a zero-bit struct, the pointer type being used during lowering is often a dummy pointer type that actually points to a non-zero-bit type, so we actually want to add 0 instead, since a zero-bit struct begins and ends at the same address.
2022-12-18llvm: fix use of invalid alignmentJacob Young
* Initialize `big_align` with 1 as 0 is not a valid alignment. * Add an assert to `alignForwardGeneric` to catch this issue earlier. * Refactor valid alignment checks to call a more descriptive function.
2022-12-18llvm: avoid creating an invalid llvm typeJacob Young
Fixes the following assertion: ``` zig: llvm/lib/IR/Type.cpp:729: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed. ```
2022-12-18llvm: fix lowering pointer to final zero-width field of a comptime valueJacob Young
* Handle a `null` return from `llvmFieldIndex`. * Add a behavior test to test this code path. * Reword this test name, which incorrectly described how pointers to zero-bit fields behave, and instead describe the actual test.
2022-12-17implement defining C variadic functionsVeikka Tuominen
2022-12-17zig fmt: fix extra whitespace with multiline stringsyujiri8
Fixes #13937
2022-12-16codegen - lower str_lit to vectorTravis Staloch
2022-12-15port packed vector elem ptr logic from stage1Veikka Tuominen
Closes #12812 Closes #13925
2022-12-09Eliminate `BoundFn` type from the languageVeikka Tuominen
Closes #9484
2022-12-09llvm: resolve all relative paths when creating DIFilesJakub Konka
This will make stack traces and debugging experience more consistent in the sense that the presence of source lines in stack traces will not be dependent on the current working directory of the running process.
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-12-04CBE and LLVM: handle unused try instructionsAndrew Kelley
In both backends they did not observe the Liveness information for try instructions. Now they do. For the C backend this is necessary for correctness; for the LLVM backend, it improves code generation.
2022-12-03Sema: fix comparisons between lazy and runtime valuesVeikka Tuominen
Closes #12498
2022-11-30llvm: make debuggers actually usableVeikka Tuominen
`@llvm.dbg.value` is absolutely useless, adding a temporary alloca to store the constant in will make it actually show up in debuggers. The effect on performance should be minimal since there is only one store and it the change is not applied to ReleaseSafe builds. ```zig fn foo(a: u32, b: []const u8, c: bool, d: enum { yes, no }) void { _ = a; _ = b; _ = c; _ = d; } ``` before: ``` Breakpoint 1, a.foo (a=<optimized out>, b=..., c=<optimized out>, d=<optimized out>) at a.zig:18 18 _ = d; ``` after: ``` Breakpoint 1, a.foo (a=1, b=..., c=false, d=yes) at a.zig:15 15 _ = a; _ = b; _ = c; _ = d; (gdb) p b $1 = {ptr = 0x20854f <a.main.anon_3888> "bar", len = 3} ```
2022-11-29std.mem.Allocator: allow shrink to failAndrew Kelley
closes #13535
2022-11-30LLVM: fix canElideLoad behavior with loopsAndrew Kelley
closes #13546
2022-11-29llvm: implement `union_init` for packed unionsVeikka Tuominen
Closes #13664
2022-11-28llvm: improve emitted debug infoVeikka Tuominen
* ensure parameter debug info is in the subroutine di scope * slit sub file path into basename and dirname Closes #12257 Closes #12665
2022-11-25Merge pull request #13627 from Vexu/tuple-declsAndrew Kelley
Implement tuple type declarations
2022-11-23Sema: implement tuple declarationsVeikka Tuominen
2022-11-22C backend: implement vector reduce and overflow intrinsicsAndrew Kelley
2022-11-21Merge pull request #13292 from mitchellh/valgrind-arm64Andrew Kelley
std: valgrind client request support for aarch64
2022-11-20llvm: add attributes to the arguments of function pointer callsVeikka Tuominen
Closes #13605
2022-11-20llvm: aarch64 C ABI: pass byref params as mutable pointersVeikka Tuominen
Closes #13597
2022-11-20llvm: use alignment of ABI return type when it differs from raw return typeVeikka Tuominen
This would previously cause miscompilations when the ABI type had bigger alignment than the raw type.
2022-11-20compute LLVMTypes in ParamTypeIterator (#13592)Guillaume Wenzek
follow up on #13376 - fixes a bug in the x86_64 C ABI. Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-11-19LLVM: add valgrind integration for x86 and aarch64Andrew Kelley
This also modifies the inline assembly to be more optimizable - instead of doing explicit movs, we instead communicate to LLVM which registers we would like to, somehow, have the correct values. This is how the x86_64 code already worked and thus allows the code to be unified across the two architectures. As a bonus, I threw in x86 support.
2022-11-18run zig fmt on everything checked by CIStevie Hryciw
2022-11-16Sema+llvm: improve handling of namespace-like unionsVeikka Tuominen
Closes #13557
2022-11-16llvm: implement arbitrary precision debug enumeratorsVeikka Tuominen
Closes #645
2022-11-12llvm: check that tuple fields have runtime bitsVeikka Tuominen
Just checking that they aren't comptime isn't enough for `@Type` constructed tuples. Closes #13531
2022-11-12llvm: correctly lower references to generic functionsVeikka Tuominen
Closes #13522
2022-11-11llvm: correct calculation of index of zero-bit fieldVeikka Tuominen
If the field comes before any non-zero-bit field then the index of the next field should be returned. Closes #13363
2022-11-11llvm: fix leaks of fully qualified namesVeikka Tuominen
2022-11-11stage2: Support modifiers in inline asmCody Tapscott
These are supported using %[ident:mod] syntax. This allows requesting, e.g., the "w" (32-bit) vs. "x" (64-bit) views of AArch64 registers. See https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers
2022-11-10stage2 llvm: Elide more loadsCody Tapscott
Adds optimizations for by-ref types to: - .struct_field_val - .slice_elem_val - .ptr_elem_val I would have expected LLVM to be able to optimize away these temporaries since we don't leak pointers to them and they are fed straight from def to use, but empirically it does not. Resolves https://github.com/ziglang/zig/issues/12713 Resolves https://github.com/ziglang/zig/issues/12638
2022-11-10stage2: Be more strict about eliding loadsCody Tapscott
This change makes any of the `*_val` instructions check whether it's safe to elide copies for by-ref types rather than performing this elision blindly. AIR instructions fixed: - .array_elem_val - .struct_field_val - .unwrap_errunion_payload - .try - .optional_payload These now all respect value semantics, as expected. P.S. Thanks to Andrew for the new way to approach this. Many of the lines here are from his recommended change, which comes with the significant advantage that loads are now as small as the intervening memory access allows. Co-authored by: Andrew Kelley <andrew@ziglang.org>
2022-11-09llvm: implement packed unionsVeikka Tuominen
Closes #13340
2022-11-04all: rename i386 to x86Ali Chraghi
2022-11-02Merge pull request #13396 from Luukdegram/fix-12880Andrew Kelley
llvm: mangle extern function names for Wasm target
2022-11-02stage2 llvm: Respect alignment for `.union_init`Cody Tapscott
Resolves #13232.
2022-11-01llvm: mangle extern Wasm functionsLuuk de Gram
When Wasm extern functions contain the same name, but have a different module name such as `extern "a"` vs `extern "b"` LLVM will currently resolve the two functions to the same symbol. By mangling the name of the symbol, we ensure the functions are resolved seperately. We mangle the name by applying <name>|<module> where module is also known as the library name.
2022-10-27Merge pull request #13288 from Vexu/opt-sliceAndrew Kelley
Optimize size of optional slices (+ some fixes)
2022-10-27Merge pull request #13257 from topolarity/ctype-fixesAndrew Kelley
stage 2: Update `CType` size/alignment