aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
AgeCommit message (Collapse)Author
2025-05-12llvm: Don't set nonnull attribute on allowzero slices.Alex Rønne Petersen
2025-05-12llvm: Set null_pointer_is_valid attribute when accessing allowzero pointers.Alex Rønne Petersen
This informs optimization passes that they shouldn't assume that a load from a null pointer invokes undefined behavior. Closes #15816.
2025-05-03std.Target: Add Cpu.Arch.or1k and basic target info.Alex Rønne Petersen
2025-05-02inline assembly: implement gcc's "%=" syntaxsamy007
2025-05-01wasm-c-abi: llvm fix struct handling + reorganizePavel Verigo
I changed to `wasm/abi.zig`, this design is certainly better than the previous one. Still there is some conflict of interest between llvm and self-hosted backend, better design will appear when abi tests will be tested with self-hosted. Resolves: #23304 Resolves: #23305
2025-04-28Merge pull request #23698 from alexrp/goff-xcoff-stubsAlex Rønne Petersen
`link`: Stub out GOFF/XCOFF linker code based on LLVM
2025-04-28std.Target: Remove Os.Tag.elfiamcu.Alex Rønne Petersen
The last Intel Quark MCU was released in 2015. Quark was announced to be EOL in 2019, and stopped shipping entirely in 2022. The OS tag was only meaningful for Intel's weird fork of Linux 3.8.7 with a special ABI that differs from the regular i386 System V ABI; beyond that, the CPU itself is just a plain old P54C (i586). We of course keep support for the CPU itself, just not Intel's Linux fork.
2025-04-27Merge pull request #22605 from dweiller/memmoveAndrew Kelley
add `@memmove` builtin
2025-04-27llvm: Fix data layout string for s390x-zos.Alex Rønne Petersen
2025-04-26std.Target: Remove Abi.gnuilp32.Alex Rønne Petersen
* This has not seen meaningful development for about a decade. * The Linux kernel port was never upstreamed. * The glibc port was never upstreamed. * GCC 15.1 recently deprecated support it. It may still make sense to support an ILP32 ABI on AArch64 more broadly (which we already have the Abi.ilp32 tag for), but, to the extent that it even existed in any "official" sense, the *GNU* ILP32 ABI is certainly dead.
2025-04-26compiler: add @memmove builtindweiller
2025-04-09compiler: Allow using LLVM's SPIR-V backend.Alex Rønne Petersen
2025-04-09Merge pull request #23501 from imreallybadatnames/masterimreallybadatnames™️
Step.Compile: use LtoMode enum for lto option
2025-04-09Fix mach-o naming for sancov sectionsSuperAuguste
2025-04-07Remove overzealous LLVM anti-instrumentation attributesSuperAuguste
2025-04-04llvm: Remove workaround for zero-length memset/memcpy on wasm.Alex Rønne Petersen
Closes #16360.
2025-04-04llvm: Use muslabin32/muslabi64 environments in the target triple.Alex Rønne Petersen
Closes #2909.
2025-04-04llvm: Allow FastISel on mips again.Alex Rønne Petersen
Closes #21215.
2025-04-04llvm: never_tail implies never_inline, so set noinline in this case too.Alex Rønne Petersen
2025-04-04llvm: Update the list of targets that use native f16/f128.Alex Rønne Petersen
Closes #22003. Closes #22013.
2025-04-04llvm: Fix i128 alignment for various targets.Alex Rønne Petersen
This ABI bug was fixed in LLVM 20.
2025-04-04llvm: Set target-abi module flag.Alex Rønne Petersen
LLVM is increasingly making use of this module flag when present.
2025-04-04std.Target: Add Abi.muslf32 and Abi.muslsf.Alex Rønne Petersen
2025-04-04std.Target: Update CPU models/features for LLVM 20.Alex Rønne Petersen
Closes #21818.
2025-04-04compiler: Updates for LLVM/Clang 20 API changes.Alex Rønne Petersen
2025-03-24Use `-unknown` when converting WASI/Emscripten target triples into LLVM triplesCarl Åstholm
The "musl" part of the Zig target triples `wasm32-wasi-musl` and `wasm32-emscripten-musl` refers to the libc, not really the ABI. For WASM, most LLVM-based tooling uses `wasm32-wasi`, which is normalized into `wasm32-unknown-wasi`, with an implicit `-unknown` and without `-musl`. Similarly, Emscripten uses `wasm32-unknown-emscripten` without `-musl`. By using `-unknown` instead of `-musl` we get better compatibility with external tooling.
2025-03-23Lower `@returnAddress` to a constant 0 in Emscripten release buildsCarl Åstholm
Emscripten currently implements `emscripten_return_address()` by calling out into JavaScript and parsing a stack trace, which introduces significant overhead that we would prefer to avoid in release builds. This is especially problematic for allocators because the generic parts of `std.mem.Allocator` make frequent use of `@returnAddress`, even though very few allocator implementations even observe the return address, which makes allocators nigh unusable for performance-critical applications like games if the compiler is unable to devirtualize the allocator calls.
2025-03-19compiler: Support more GCC code models and fix the mapping to LLVM code models.Alex Rønne Petersen
Closes #22517.
2025-03-08Merge pull request #22998 from jacobly0/x86_64-rewriteAndrew Kelley
x86_64: rewrite aggregate init
2025-03-08llvm: Replace DataLayoutBuilder with a simple target -> string switch.Alex Rønne Petersen
This should be a lot easier to maintain. It's also a small step towards eventually making the builder API parse the data layout string in order to answer layout questions that we need to ask during code generation.
2025-03-07x86_64: implement write register splittingJacob Young
2025-02-27Move the compiler's LLVM bitcode builder to std.zig.llvm.Alex Rønne Petersen
2025-02-24Merge pull request #22154 from alexrp/disable-intrinsicsAlex Rønne Petersen
compiler: Implement `@disableIntrinsics()` builtin function.
2025-02-24llvm: Fix C ABI integer promotion for loongarch64.Alex Rønne Petersen
It appears to just be a 1:1 copy of riscv64, including the super weird sign extension quirk for u32. Contributes to #21671.
2025-02-23compiler: Implement @disableIntrinsics() builtin function.Alex Rønne Petersen
Closes #21833. Closes #22110.
2025-02-22zig build fmtAndrew Kelley
2025-02-23Merge pull request #22903 from alexrp/llvm-nobuiltin-memcpy-inlineAlex Rønne Petersen
`llvm`: Use inline variants of `memcpy`/`memset` intrinsics when using `-fno-builtin`
2025-02-22llvm: Use inline variants of memcpy/memset intrinsics when using -fno-builtin.Alex Rønne Petersen
This is a correctness issue: When -fno-builtin is used, we must assume that we could be compiling the memcpy/memset implementations, so generating calls to them is problematic.
2025-02-22llvm.Builder: Update some intrinsic definitions for LLVM 19.Alex Rønne Petersen
2025-02-21fix `-fsanitize-coverage-trace-pc-guard` and fuzzer support for C compile unitsXavier Bouchoux
- allow `-fsanitize-coverage-trace-pc-guard` to be used on its own without enabling the fuzzer. (note that previouly, while the flag was only active when fuzzing, the fuzzer itself doesn't use it, and the code will not link as is.) - add stub functions in the fuzzer to link with instrumented C code (previously fuzzed tests failed to link if they were calling into C): while the zig compile unit uses a custom `EmitOptions.Coverage` with features disabled, the C code is built calling into the clang driver with "-fsanitize=fuzzer-no-link" that automatically enables the default features. (see https://github.com/llvm/llvm-project/blob/de06978ebcff5f75913067b019d2d522d0be0872/clang/lib/Driver/SanitizerArgs.cpp#L587) - emit `-fsanitize-coverage=trace-pc-guard` instead of `-Xclang -fsanitize-coverage-trace-pc-guard` so that edge coverrage is enabled by clang driver. (previously, it was enabled only because the fuzzer was)
2025-02-17std.Target: Remove functions that just wrap component functions.Alex Rønne Petersen
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look at multiple components of the target. But functions like isWasm(), isDarwin(), isGnu(), etc only exist to save 4-8 characters. I don't think this is a good enough reason to keep them, especially given that: * It's not immediately obvious to a reader whether target.isDarwin() means the same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar functions *do* look at multiple components. * It's not clear where we would draw the line. The logical conclusion before this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(), Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand. * It's nice to just have a single correct way of doing something.
2025-02-17std.builtin: Rename CallingConvention.propeller1_sysv to propeller_sysv.Alex Rønne Petersen
2025-02-17std.builtin: Rename CallingConvention.wasm_watc to wasm_mvp.Alex Rønne Petersen
2025-02-17std.builtin: Remove CallingConvention.arm_(apcs,aapcs16_vfp).Alex Rønne Petersen
* arm_apcs is the long dead "OABI" which we never had working support for. * arm_aapcs16_vfp is for arm-watchos-none which is a dead target that we've dropped support for.
2025-02-17std.Target: Remove Cpu.Arch.propeller2 and use a CPU feature instead.Alex Rønne Petersen
2025-02-17std.Target: Remove Cpu.Arch.spu_2.Alex Rønne Petersen
This was for a hobby project that appears to be dormant for now. This can be added back if the project is resumed in the future.
2025-01-31Sema: introduce all_vector_instructions backend featureJacob Young
Sema is arbitrarily scalarizing some operations, which means that when I try to implement vectorized versions of those operations in a backend, they are impossible to test due to Sema not producing them. Now, I can implement them and then temporarily enable the new feature for that backend in order to test them. Once the backend supports all of them, the feature can be permanently enabled. This also deletes the Air instructions `int_from_bool` and `int_from_ptr`, which are just bitcasts with a fixed result type, since changing `un_op` to `ty_op` takes up the same amount of memory.
2025-01-30compiler: add `intcast_safe` AIR instructionmlugg
This instruction is like `intcast`, but includes two safety checks: * Checks that the int is in range of the destination type * If the destination type is an exhaustive enum, checks that the int is a named enum value This instruction is locked behind the `safety_checked_instructions` backend feature; if unsupported, Sema will emit a fallback, as with other safety-checked instructions. This instruction is used to add a missing safety check for `@enumFromInt` truncating bits. This check also has a fallback for backends which do not yet support `safety_checked_instructions`. Resolves: #21946
2025-01-24compiler: yet more panic handler changesmlugg
* `std.builtin.Panic` -> `std.builtin.panic`, because it is a namespace. * `root.Panic` -> `root.panic` for the same reason. There are type checks so that we still allow the legacy `pub fn panic` strategy in the 0.14.0 release. * `std.debug.SimplePanic` -> `std.debug.simple_panic`, same reason. * `std.debug.NoPanic` -> `std.debug.no_panic`, same reason. * `std.debug.FormattedPanic` is now a function `std.debug.FullPanic` which takes as input a `panicFn` and returns a namespace with all the panic functions. This handles the incredibly common case of just wanting to override how the message is printed, whilst keeping nice formatted panics. * Remove `std.builtin.panic.messages`; now, every safety panic has its own function. This reduces binary bloat, as calls to these functions no longer need to prepare any arguments (aside from the error return trace). * Remove some legacy declarations, since a zig1.wasm update has happened. Most of these were related to the panic handler, but a quick grep for "zig1" brought up a couple more results too. Also, add some missing type checks to Sema. Resolves: #22584 formatted -> full
2025-01-22compiler: pass error return traces everywheremlugg