aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
AgeCommit message (Collapse)Author
2023-09-21LLVM: fix UAF when lowering debug info for structsAndrew Kelley
Gotta call the get() function inside the loop if the loop adds anything to InternPool.
2023-09-21InternPool,Sema,type,llvm: alignment fixesmlugg
This changeset fixes the handling of alignment in several places. The new rules are: * `@alignOf(T)` where `T` is a runtime zero-bit type is at least 1, maybe greater. * Zero-bit fields in `extern` structs *do* force alignment, potentially offsetting following fields. * Zero-bit fields *do* have addresses within structs which can be observed and are consistent with `@offsetOf`. These are not necessarily all implemented correctly yet (see disabled test), but this commit fixes all regressions compared to master, and makes one new test pass.
2023-09-21compiler: get codegen of behavior tests working on at least one backendmlugg
We're hitting false compile errors, but this is progress!
2023-09-21fix regressions from this branchAndrew Kelley
2023-09-21compiler: move struct types into InternPool properAndrew Kelley
Structs were previously using `SegmentedList` to be given indexes, but were not actually backed by the InternPool arrays. After this, the only remaining uses of `SegmentedList` in the compiler are `Module.Decl` and `Module.Namespace`. Once those last two are migrated to become backed by InternPool arrays as well, we can introduce state serialization via writing these arrays to disk all at once. Unfortunately there are a lot of source code locations that touch the struct type API, so this commit is still work-in-progress. Once I get it compiling and passing the test suite, I can provide some interesting data points such as how it affected the InternPool memory size and performance comparison against master branch. I also couldn't resist migrating over a bunch of alignment API over to use the log2 Alignment type rather than a mismash of u32 and u64 byte units with 0 meaning something implicitly different and special at every location. Turns out you can do all the math you need directly on the log2 representation of alignments.
2023-09-19llvm: update riscv floating-point c abi for LLVM 17Jacob Young
2023-09-19llvm: update data layout computation to LLVM 17Jacob Young
2023-09-19llvm: update address space definitions to LLVM 17Jacob Young
2023-09-19LLVM 17 std lib updates and fixesAndrew Kelley
* some manual fixes to generated CPU features code. in the future it would be nice to make the script do those automatically. I suspect the sm_90a thing is a bug in LLVM. * add liteos to various target OS switches. I know nothing about this OS; someone will need to work specifically on support for this OS when the time comes to support it properly in zig. * while waiting for the compiler, I went ahead and made more conservative choices about when to use `inline` in std/Target.zig
2023-09-18LLVM: cache LLVM struct field indexesAndrew Kelley
This is an optimization to avoid O(N) field index lookups. It's also nicer in terms of DRY; the only tradeoff is memory usage.
2023-09-12InternPool: prevent anon struct UAF bugs with type safetyAndrew Kelley
Instead of using actual slices for InternPool.Key.AnonStructType, this commit changes to use Slice types instead, which store a long-lived index rather than a pointer. This is a follow-up to 7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b.
2023-08-28llvm/cbe: support slice in `@prefetch`Jacob Young
Closes #16967
2023-08-22compiler: move unions into InternPoolAndrew Kelley
There are a couple concepts here worth understanding: Key.UnionType - This type is available *before* resolving the union's fields. The enum tag type, number of fields, and field names, field types, and field alignments are not available with this. InternPool.UnionType - This one can be obtained from the above type with `InternPool.loadUnionType` which asserts that the union's enum tag type has been resolved. This one has all the information available. Additionally: * ZIR: Turn an unused bit into `any_aligned_fields` flag to help semantic analysis know whether a union has explicit alignment on any fields (usually not). * Sema: delete `resolveTypeRequiresComptime` which had the same type signature and near-duplicate logic to `typeRequiresComptime`. - Make opaque types not report comptime-only (this was inconsistent between the two implementations of this function). * Implement accepted proposal #12556 which is a breaking change.
2023-08-17InternPool: safer enum APIAndrew Kelley
The key changes in this commit are: ```diff - names: []const NullTerminatedString, + names: NullTerminatedString.Slice, - values: []const Index, + values: Index.Slice, ``` Which eliminates the slices from `InternPool.Key.EnumType` and replaces them with structs that contain `start` and `len` indexes. This makes the lifetime of `EnumType` change from expiring with updates to InternPool, to expiring when the InternPool is garbage-collected, which is currently never. This is gearing up for a larger change I started working on locally which moves union types into InternPool. As a bonus, I fixed some unnecessary instances of `@as`.
2023-08-15InternPool: preserve indices of builtin types when resolvedmlugg
Some builtin types have a special InternPool index (e.g. `.type_info_type`) so that AstGen can refer to them before semantic analysis. Unfortunately, this previously led to a second index existing to refer to the type once it was resolved, complicating Sema by having the concept of an "unresolved" type index. This change makes Sema modify these InternPool indices in-place to contain the expanded representation when resolved. The analysis of the corresponding decls is caught in `Module.semaDecl`, and a field is set on Sema telling it which index to place struct/union/enum types at. This system could break if `std.builtin` contained complex decls which evaluate multiple struct types, but this will be caught by the assertions in `InternPool.resolveBuiltinType`. The AstGen result types which were disabled in 6917a8c have been re-enabled. Resolves: #16603
2023-08-09llvm: enable even without libllvm linkedJacob Young
2023-08-08llvm: force strip without libllvm to avoid unimplemented behaviorJacob Young
Also fix deinit bugs.
2023-08-08llvm: remove dependence on llvm data layout alignmentJacob Young
by just using the zig alignment and letting llvm promote it as desired
2023-08-08llvm: fix alias issuesJacob Young
2023-08-08llvm: finish converting globalsJacob Young
2023-08-08Builder: fix enough bugs to pass the behavior testsJacob Young
without using any information from the LLVM API
2023-08-08llvm: cleanup even more unused LLVM API bindingsJacob Young
2023-08-08llvm: finish converting instructionsJacob Young
2023-08-08llvm: finish converting intrinsicsJacob Young
2023-08-08llvm: convert vector reduction intrinsicsJacob Young
Scratch that thing I said about one pass. :)
2023-08-08llvm: finish converting attributes to use Builder and the C LLVM APIJacob Young
2023-08-08llvm: convert intrinsics to using `Builder`Jacob Young
2023-08-06Use new LLVM IR builder API in bit op loweringantlilja
2023-08-06Use new LLVM builder API in buildFloatOPantlilja
2023-08-01llvm: fix data layout calculation for experimental llvm targetsJacob Young
Closes #16616
2023-07-31std: finish cleanup up asmJacob Young
This also required implementing the necessary syntax in the x86_64 backend.
2023-07-29Merge pull request #16611 from xxxbxxx/packed-structJacob Young
codegen: fix various packed struct issues Closes #16609 Closes #15337
2023-07-29llvm: support read-write output constraints in assemblyJacob Young
Closes #15227
2023-07-29codegen: fix access to byte-aligned nested packed struct elemsXavier Bouchoux
When acessing a packed struct member via a byte aligned ptr (from the optimisation in Sema.structFieldPtrByIndex()) the codegen must apply the parent ptr packed_offset in addition to the field offset itself. resolves https://github.com/ziglang/zig/issues/16609
2023-07-29llvm: partial fix of store undefined to packed result locationXavier Bouchoux
prefer marking too few undefined bits, rather than too many that may overwrite nearby values. partially resolves https://github.com/ziglang/zig/issues/15337
2023-07-28llvm: fix SysV C abi for structs smaller than two eightbytesJacob Young
Closes #16038 Closes #16288
2023-07-27LLVM: always add argument attributes to callsAndrew Kelley
These are needed for correctness. There's no reason to only add them for function pointers. closes #16290
2023-07-26llvm: fix data layout on iosJacob Young
Closes #16549
2023-07-25codegen/llvm: fix memset with vectors smaller than one byteXavier Bouchoux
The special case to take advantage of llvm's intrinsic was generating invalid llvm ir: ``` Invalid bitcast %60 = bitcast <2 x i2> %59 to i8, !dbg !3122 thread 145453 panic: LLVM module verification failed ```
2023-07-23llvm: convert global assemblyJacob Young
2023-07-23llvm: convert inline assemblyJacob Young
Also, implement TODOs from a previous commit.
2023-07-23llvm: fix datalayout generation for more targetsJacob Young
Closes #16482
2023-07-23llvm: convert attributes and non-intrinsic callsJacob Young
2023-07-20llvm: cleanup LLVM IR dumpingJacob Young
2023-07-19llvm: fix various crashesJacob Young
2023-07-19llvm: minor fixesJacob Young
2023-07-19llvm: convert most instructionsJacob Young
2023-07-19llvm: convert cursor positioningJacob Young
2023-07-19llvm: convert basic block creationJacob Young
2023-07-19llvm: finish converting constantsJacob Young