Commit Graph

5508 Commits

Author SHA1 Message Date
Feoramund
eb051a2d7c Re-enable static map calls on AMD64 SysV 2025-05-18 17:13:39 -04:00
gingerBill
dd31075c33 Merge pull request #5171 from laytan/fix-global-and-static-any
fix global and static any
2025-05-18 16:59:34 +01:00
Feoramund
591118c688 Use --sysroot instead of -Wl,-syslibroot on Darwin
This keeps the linker from using the wrong SDK and mirrors how we build
the Odin compiler itself in `build_odin.sh`.
2025-05-18 11:11:02 -04:00
Laytan Laats
c35a45e823 fix global and static any
Fixes #4627
2025-05-17 16:49:30 +02:00
Jeroen van Rijn
7c80df4830 @(init), @(fini) and @(export) procedures are classified as used.
For the purposes of `-vet-unused-procedures`, exported procedures and `@(init)` and `@(fini)` are now disregarded.
2025-05-17 16:22:47 +02:00
gingerBill
8337b7cccb Merge pull request #5162 from 0xrsp/tounsigned
new compiler intrinsics type_integer_to_unsigned, type_integer_to_unsigned
2025-05-17 11:51:57 +01:00
tf2spi
2f636886a5 Add debug info for labels (#4385)
* Emit label debug info w/o location

* Insert debug label call

* Slight refactor for later fix

* Improve debug labels for block statements

* Improve debug info with for loops

* Generate label lbBlocks w/ debug

* Lightly refactor lb_add_debug_label

* Revise comments, add null check assertion

* Use LLVM-C API for debug labels

* Prefer C DILabel API for POSIX, fallback to CPP

* Use version check for LLVM-C DILabel
2025-05-15 22:11:06 +02:00
Laytan Laats
2d00f8d69d fix compat with earlier llvm versions 2025-05-15 19:20:04 +02:00
0xrsp
649cad2f1b add: type_integer_to_* error messages 2025-05-15 01:12:06 +09:30
0xrsp
ea806f1d5e new compiler intrinsics type_integer_to_unsigned,type_integer_to_signed 2025-05-15 01:00:40 +09:30
Jeroen van Rijn
ed56a7ca10 Parse odin version date out of HEAD commit if available 2025-05-13 18:09:30 +02:00
gingerBill
0a12c464ab Change Odin's RTTI section name to .odinti 2025-05-13 08:58:02 +01:00
gingerBill
d2d5c40e76 Handle "untyped" case 2025-05-12 16:49:59 +01:00
gingerBill
d2d4ac8120 Add compress_values 2025-05-12 15:29:43 +01:00
Laytan Laats
f9b9e9e7dc some ABI fixups and improvements
Started with trying to enable asan in the CI for MacOS, noticed it wasn't enabled on the `tests/internal`
folder, it came up with a couple of issues with the abi/OdinLLVMBuildTransmute that this also solves.

- Looking at clang output for arm64, we should be promoting `{ i64, i32 }` to `{ i64, i64 }`
- after doing the previous point, I noticed this is not handled well in OdinLLVMBuildTransmute
  which was emitting loads and stores into the space of a value that was alignment, asan does not want this,
  looking at clang output again, a memcpy is the appropriate way of handling this.
- Having done this we don't need the hacky "return is packed" set anymore in the amd64 sysv ABI anymore either
2025-05-09 23:03:17 +02:00
gingerBill
8a225a6887 Place RTTI into its own section .odin-rtti 2025-05-09 11:07:53 +01:00
gingerBill
23aff08556 Merge pull request #5117 from bogwi/bug/5024
Bug/5024
2025-05-09 08:35:16 +01:00
gingerBill
92df892f25 Merge pull request #5064 from harold-b/hb/objc-classes
Add support for Objective-C class implementation
2025-05-08 12:58:33 +01:00
Laytan Laats
ad4866653a fix disposing builder when not created
Fixes #5128

p->builder is created in lb_begin_procedure_body, but that isn't called
if there is no body, and we were still calling dispose at that point.

Moved it into lb_end_procedure_body to match.
2025-05-07 14:39:51 +02:00
gingerBill
90a30a145a Merge pull request #5122 from Lperlind/asan-allocators
Add asan support for various allocators and stack unpoisoning
2025-05-07 10:21:16 +01:00
Lucas Perlind
46e0c7ad74 Cleanup 2025-05-07 11:30:58 +10:00
gingerBill
0cf5b5984d Merge pull request #5108 from Barinzaya/core-simd-indices-redadd-redmul
Alternate `reduce_add`/`reduce_mul` intrinsics
2025-05-06 15:46:49 +01:00
Jeroen van Rijn
8097b59e30 Also allow comparing SOA pointers against each other
This compares the data pointer *and* the index.

```odin
package scratch

import "core:fmt"

Foo :: struct {a, b: int}

main :: proc() {
    a := new(#soa[dynamic]Foo)
    a^ = make(#soa[dynamic]Foo, 12, 12)

    b := new(#soa[dynamic]Foo)
    b^ = make(#soa[dynamic]Foo, 12, 12)

    fmt.printfln("&a[0]: %p, &b[0]: %p, Same: %v", &a[0], &b[0], &a[0] == &b[0]) // Same: false
    fmt.printfln("&a[0]: %p, &b[0]: %p, Same: %v", &a[0], &b[1], &a[0] == &b[1]) // Same: false
    fmt.printfln("&a[0]: %p, &b[0]: %p, Same: %v", &a[0], &b[2], &a[0] == &b[2]) // Same: false

    fmt.printfln("&a[0]: %p, &a[1]: %p, Same: %v", &a[0], &a[1], &a[0] == &a[1]) // Same: false
    fmt.printfln("&a[1]: %p, &a[2]: %p, Same: %v", &a[1], &a[2], &a[1] == &a[2]) // Same: false
    fmt.printfln("&a[2]: %p, &a[3]: %p, Same: %v", &a[2], &a[3], &a[2] == &a[3]) // Same: false

    fmt.printfln("&a[0]: %p, &a[0]: %p, Same: %v", &a[0], &a[0], &a[0] == &a[0]) // Same: true
    fmt.printfln("&a[1]: %p, &a[1]: %p, Same: %v", &a[1], &a[1], &a[1] == &a[1]) // Same: true
    fmt.printfln("&a[2]: %p, &a[2]: %p, Same: %v", &a[2], &a[2], &a[2] == &a[2]) // Same: true
}
```
2025-05-06 15:10:08 +02:00
bogwi
904a64a45e Add support for SoaPointer nil comparison in lb_emit_comp_against_nil 2025-05-06 14:21:18 +09:00
Lucas Perlind
83bc2d3c4a Add asan support for various allocators 2025-05-06 14:55:50 +10:00
Barinzaya
dd5b7852ce Added alternate reduce-add/reduce-mul intrinsics.
The new reduce_add/reduce_mul procs perform the corresponding arithmetic
reduction in different orders than sequential order. These alternative
orders can often offer better SIMD hardware utilization.

Two different orders are added: pair-wise (operating on pairs of
adjacent elements) or bisection-wise (operating element-wise on the
first and last N/2 elements of the vector).
2025-05-05 16:38:45 -04:00
Jeroen van Rijn
2224911aca Fix type_union_tag_offset when all members are zero sized 2025-05-05 18:09:54 +02:00
bogwi
3c0ba5bb55 CHECK 4 done
The original errors:
1. `5024.odin(127:15) Error: Invalid use of a polymorphic type 'List($T)' in variable declaration`
2. `5024.odin(129:17) Error: Cannot determine polymorphic type from parameter: 'invalid type' to 'List($T)'`
Are gone. We now have a single, different error:
`5024.odin(124:28) Error: Unspecialized polymorphic types are not allowed in procedure parameters, got List($T)`

This error points directly to the `list : List($T)` parameter within the `List_Filter` procedure definition. This seems much more relevant to the actual problem (the interaction between the generic `List_Filter` and the concrete `default_filter`) than the original error about the variable declaration.

While this new error message might not be exactly pinpointing the default parameter issue, it correctly identifies the problematic procedure definition (`List_Filter`) as the source of the error, rather than the variable declaration (`my_list`). This seems like a step in the right direction for improving the error reporting for this kind of scenario.
2025-05-05 22:39:03 +09:00
Harold Brenes
14e25c0f2a Fix lb_get_objc_type_encoding missing matrix and simdvec encodings and minor fixes. 2025-05-05 09:07:50 -04:00
gingerBill
36945079f8 Add intrinsics.simd_indices 2025-05-05 11:41:54 +01:00
bogwi
af6b763449 CHECK 3 done
Enhance support for polymorphic procedures in type checking

1. In src/check_type.cpp, added special handling for polymorphic procedures used as default parameter values. We now allow a polymorphic procedure to be used as a default parameter value, even when its type parameters can't be immediately determined.

2. In src/check_expr.cpp, we modified the check_is_assignable_to_with_score function to handle the special case of assigning a polymorphic procedure as a default parameter. The function now allows a polymorphic procedure to be assigned to a concrete procedure type in this specific context.
2025-05-05 17:53:32 +09:00
bogwi
af0e067a12 CHECK 2 done
Add support for handling generic types in LLVM backend

- Updated `lb_type_internal` to return a pointer type for unspecialized generics.
- Modified `write_type_to_canonical_string` to handle specialized generics without panicking.
- Enhanced `default_type` to return the default type of specialized generics when applicable.
2025-05-05 16:58:14 +09:00
bogwi
ee8aeea381 CHECK 1 done
Fix panic in LLVM backend when using generic procedure with default arguments

- Fixed panic in `llvm_backend_proc.cpp` when using unspecialized polymorphic procedures as defaults.
- Ensured correct type inference when generic procedures are used as default parameters.
2025-05-05 16:50:40 +09:00
Jeroen van Rijn
c96d8237ba Clarify error messages for types that aren't simply comparable.
Previously, it implied that these are different types:
```
W:/Scratch/scratch.odin(17:5) Error: Cannot compare expression, operator '==' not defined between the types 'Handle_Map($T=u32, $HT=u32, $Max=10000)' and 'Handle_Map($T=u32, $HT=u32, $Max=10000)'
    if m == {} {
       ^~~~~~^
```
Now:
```
W:/Scratch/scratch.odin(20:5) Error: Cannot compare expression. Type 'Handle_Map($T=u32, $HT=u32, $Max=10000)' is not simply comparable, so operator '==' is not defined for it.
	if m == {} {
	   ^~~~~~^
```
2025-05-03 22:31:01 +02:00
Harold Brenes
be2e4dec7d Resolve other TODOs 2025-05-03 13:06:57 -04:00
Jeroen van Rijn
9681d88cd3 Fix #5107
Fixes #5107 by checking whether `result_count` is non-zero before indexing `type->Proc.results->Tuple.variables`.
2025-05-03 14:42:20 +02:00
Harold Brenes
fc082f5ea5 Remove some TODO. Leave important note 2025-05-03 03:21:03 -04:00
Harold Brenes
6d18560ca3 Move unconditionally exporting Objective-C methods to the right location 2025-05-03 03:09:31 -04:00
Harold Brenes
cf3830a6a8 Fix checker errors. 2025-05-03 03:09:31 -04:00
Harold Brenes
33d37c72f9 Register all classes unconditionally 2025-05-03 03:09:31 -04:00
Harold Brenes
a00b91577d Prevent multiple uses of the same Objective-C class name 2025-05-03 03:09:30 -04:00
Harold Brenes
5f0b47c373 Implement all checker specification for Objective-C class implementations and objc_ivar_get intrinsic 2025-05-03 00:59:33 -04:00
Jeroen van Rijn
30c6fea9e9 Allow polymorphic #simd array as return type 2025-05-02 15:38:43 +02:00
gingerBill
19fe75f020 Merge pull request #5098 from laytan/fix-nan-comparisons
fix variable NaN comparisons
2025-05-02 13:00:42 +01:00
gingerBill
777c33a9a1 Merge pull request #5102 from Lperlind/attribute-no-sanitize-address
Add attribute @(no_sanitize_address)
2025-05-01 12:16:10 +01:00
Lucas Perlind
5c73b4ef58 Add attribute @(no_sanitize_address)
The purposes of this attribute is to let procedures opt-out of being
instrumented with asan. Typically an allocator that includes 'in-band'
meta-data will be accessing poisoned values (such as tlsf).

Making asan work with these allocators becomes very challenging so
just being to ignore asan within specific allocator procedures
makes it easier to reason and removes the need to temporarily
poison and unpoison allocator data.
2025-05-01 20:42:21 +10:00
Harold Brenes
0746127654 Minor fixes in data type usage and style. 2025-04-30 22:16:53 -04:00
Harold Brenes
1505edef01 Change ivar offsets from u32 to (odin base type) int/native pointer size. 2025-04-30 22:09:33 -04:00
Harold Brenes
dc8692b504 Use correct alignment value for class_addIvar. 2025-04-30 21:52:29 -04:00
Harold Brenes
998ed79738 Go back to objc_ivar_get instead of ivar_get. 2025-04-30 20:43:05 -04:00