aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
AgeCommit message (Collapse)Author
2022-09-08stage2: fix building for 32-bit targetsAndrew Kelley
2022-09-08llvm: handle pointers in packed structs in more placesVeikka Tuominen
Closes #12776
2022-09-04stage2 llvm: implement aarch64 C ABIVeikka Tuominen
... at least enough to pass all the current tests.
2022-09-04llvm: fix the `type` parameter of `GlobalAlias`riChar
Closes 12680
2022-09-03stage2 llvm: improve handling of i128 on Windows C ABIVeikka Tuominen
2022-09-03Sema: only ABI sized packed structs are extern compatibleVeikka Tuominen
2022-09-02stage2 llvm: correct handling of zero-bit types in unionFieldPtrVeikka Tuominen
Pointers to zero-bit types are not zero-bit types so the function should return something. Closes #12716
2022-09-02stage2 llvm: fix passing packed structs to callconv(.C) functionsVeikka Tuominen
Closes #12704
2022-08-30avoid exposing supportsTailCall in the standard libraryAndrew Kelley
This is problematic because in practice it depends on whether the compiler backend supports it too, as evidenced by the TODO comment about LLVM not supporting some architectures that in fact do support tail calls. Instead this logic is organized strategically in src/target.zig, part of the internal compiler source code, and the behavior tests in question duplicate some logic for deciding whether to proceed with the test. The proper place to expose this flag is in `@import("builtin")` - the generated source file - so that third party compilers can advertise whether they support tail calls.
2022-08-30stage2 llvm: use tag value instead of field index in airUnionInitVeikka Tuominen
Closes #12656
2022-08-30Sema: improve handling of always_tail call modifierVeikka Tuominen
Closes #4301 Closes #5692 Closes #6281 Closes #10786 Closes #11149 Closes #11776
2022-08-25LLVM: fix missing alignment on wrapping instructionsAndrew Kelley
Previously, when lowering AIR instructions `wrap_errunion_payload`, `wrap_errunion_err`, and `wrap_optional`, the LLVM backend would create an alloca instruction to store the result, but did not set the alignment on it. This caused UB which went undetected for a long time until we started enabling the stack protector. Closes #12594 Unblocks #12508 Inspires #12634 Tests passed locally: * test-behavior * test-cases
2022-08-24stage2: explicitly tagged enums no longer have one possible valueAndrew Kelley
Previously, Zig had inconsistent semantics for an enum like this: `enum(u8){zero = 0}` Although in theory this can only hold one possible value, the tag `zero`, Zig no longer will treat the type this way. It will do loads and stores, as if the type has runtime bits. Closes #12619 Tests passed locally: * test-behavior * test-cases
2022-08-22llvm: add valgrind client request integration for x86_64Andrew Kelley
closes #12500
2022-08-22Sema: allow optional pointers in packed structsVeikka Tuominen
Closes #12572
2022-08-21Sema: handle union and enum field order being differentVeikka Tuominen
Closes #12543
2022-08-19LLVM: add DLL export attributeAndrew Kelley
This was present in stage1 but missing from self-hosted.
2022-08-19stage2: implement stack protectorsAndrew Kelley
This is one of the final remaining TODOs for the LLVM backend.
2022-08-18std.Target gains ObjectFormat fieldAndrew Kelley
2022-08-18LLVM: disable the ABI size safety checkAndrew Kelley
There still more instances of this check being tripped during behavior tests that we need to fix before we can enable this.
2022-08-18stage2: agree with LLVM that `@alignOf(u128)` is 8Andrew Kelley
on x86_64 and similar targets.
2022-08-12stage2: check for zero in `@intToError` safetyVeikka Tuominen
2022-08-12stage2: generate a switch for `@errSetCast` safetyVeikka Tuominen
2022-08-10stage2 llvm: implement more C ABIVeikka Tuominen
2022-08-10LLVM: respect linksection for exported variablesAndrew Kelley
2022-08-10stage2: Implement explicit backing integers for packed structsIsaac Freund
Now the backing integer of a packed struct type may be explicitly specified with e.g. `packed struct(u32) { ... }`.
2022-08-05stage2: add runtime safety for invalid enum valuesVeikka Tuominen
2022-08-01Removed param_names from Fn inside Module.zigantlilja
Removed the copy of param_names inside of Fn and changed to implementation of getParamName to fetch to parameter name from the ZIR. The signature of getParamName was also changed to take an additional *Module argument.
2022-07-31stage2 LLVM: Pass inline assembly outputs directly when not targeting memoryCody Tapscott
This change provides a basic implementation of #2349 for stage2. There's still quite a lot of work before this logic is as complete as what's in Clang (https://github.com/llvm/llvm-project/blob/b3645353041818f61e2580635409ddb81ff5a272/clang/lib/CodeGen/CGStmt.cpp#L2304-L2795), particularly considering the diversity of constraints across targets. It's probably not worth doing the complete work until there's a clearer picture for constraints in Zig's future dedicated ASM syntax, but at least this gives us a small improvement for now. As a bonus, this also fixes a bug with how we were handling `_` identifiers.
2022-07-27LLVM: fix returning extern union with C callconvAndrew Kelley
2022-07-27LLVM: fix lowering byte-aligned packed struct field pointersAndrew Kelley
2022-07-26LLVM: add probe-stack function attributeAndrew Kelley
2022-07-25wasm: Only allow lowering C-ABI compatible typesLuuk de Gram
2022-07-25llvm: correctly lower c-abi for Wasm targetLuuk de Gram
When lowering the return type for Wasm if the calling convention is `C`, it now correctly lower it according to what clang does as specified in: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md This makes use of the same logic as the Wasm backend, ensuring the generated code does not diverge in function signatures. When passing arguments accross the C-ABI for the Wasm target, we want slightly different behavior than x86_64. For instance: a struct with multiple fields must always be passed by reference, even if its ABI size fits in a single integer. However, we do pass larger integers such as 128bit by value, which LLVM will correctly lower to use double arguments instead.
2022-07-24LLVM: notice the soft_float CPU featureAndrew Kelley
when deciding whether to lower to x86_fp80 instructions, or softfloat instructions. Closes #10847 Closes #12090
2022-07-24stage2: implement `noinline fn`Meghan
2022-07-23stage2: implement `@setFloatMode`Veikka Tuominen
2022-07-23Sema: bad union field access safetyVeikka Tuominen
2022-07-22Merge pull request #12198 from Vexu/stage2Andrew Kelley
Sema: fix loading and storing of optional pointers represented as pointers
2022-07-22stage2: fix airIsErr when `is_ptr == true`Veikka Tuominen
2022-07-21LLVM: fix lowering of structs with underaligned fieldsAndrew Kelley
When lowering a struct type to an LLVM struct type, keep track of whether there are any underaligned fields. If so, then make it a packed llvm struct. This works because we already insert manual padding bytes regardless. We could unconditionally use an LLVM packed struct; the reason we bother checking for underaligned fields is that it is a conservative choice, in case LLVM handles packed structs less optimally. A future improvement could simplify this code by unconditionally using packed LLVM structs and then make sure measure perf is unaffected. closes #12190
2022-07-20stage2 llvm: fix handling of pointer fields in packed structsVeikka Tuominen
2022-07-19LLVM: change commentary on isByRefAndrew Kelley
This branch originally started out as a potential workaround to address #11450. It did not solve that problem, however, it did end up fixing #11498!
2022-07-19LLVM: lower all error unions as byref=trueAndrew Kelley
Same reasoning as previous commit.
2022-07-19LLVM: lower all structs as byref=trueAndrew Kelley
Same reasoning as previous commit.
2022-07-19LLVM: lower optional types as byref=trueAndrew Kelley
This is a possible workaround for https://github.com/llvm/llvm-project/issues/56585 On my computer it makes stage3-release go from false positive compilation errors on the behavior tests to "segmentation fault". Is this forwards progress or backwards progress? I have no idea. See #11450
2022-07-19stage2: Change optional non-null field to i8Cody Tapscott
This is a workaround for https://github.com/llvm/llvm-project/issues/56585 which causes writes to i1 in memory to be optimized to an incorrect value. Unfortunately, this does not save users from running into this bug with u1 in their own types. However, this does seem to be enough to get the behavior tests working. This resolves #11450 on my machine.
2022-07-14LLVM: disable the ABI size safety checkAndrew Kelley
There are many more instances of this check being tripped that we need to fix before we can enable this.
2022-07-14LLVM: fix ABI size of optional and error union typesAndrew Kelley
Previously, the Zig ABI size and LLVM ABI size of these types disagreed sometimes. This code also corrects the logging messages to not trigger LLVM assertions.
2022-07-14Revert "stage2 llvm: Use unpacked struct for unions and arrays"Andrew Kelley
This reverts commit 2eaef84ebe968224b0cf25206abf12ea1c5e0f5a. Here is a motivating example: ```zig const E = union(enum) { A: [9]u8, B: u64, }; ``` ```llvm %test2.E = type { { i64, [1 x i8] }, i1, [6 x i8] } ``` ``` error(codegen): when lowering test2.E, Zig ABI size = 16 but LLVM ABI size = 24 ```