odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.17k stars 550 forks source link

Passing struct containing 128-bit integer panics #3707

Closed Feoramund closed 1 month ago

Feoramund commented 1 month ago

The following program crashes with src/llvm_abi.cpp(876): Panic: Unhandled RegClass:

package regcrash

S :: struct { u: u128 }
p :: proc(s: S) { }

main :: proc () {
    s: S
    p(s)
}

odin report:

    Odin:    dev-2024-06:575e5a255
    OS:      Arch Linux, Linux 6.9.3-arch1-1
    CPU:     12th Gen Intel(R) Core(TM) i7-12700K
    RAM:     31913 MiB
    Backend: LLVM 17.0.6

Backtrace:

* thread #1, name = 'odin', stop reason = signal SIGILL: illegal operand
  * frame #0: 0x0000555555744dab odin`lbAbiAmd64SysV::llreg(c=0x00005555559a2110, reg_classes=0x00007fffffffb4c0, type=0x0000555555a74390) at llvm_abi.cpp:876:6
    frame #1: 0x000055555574419a odin`lbAbiAmd64SysV::amd64_type(c=0x00005555559a2110, type=0x0000555555a74390, attribute_kind=Amd64TypeAttribute_ByVal, calling_convention=ProcCC_Odin) at llvm_abi.cpp:664:16
    frame #2: 0x00005555557427f8 odin`lbAbiAmd64SysV::abi_info(c=0x00005555559a2110, arg_types=0x00007fffecb73480, arg_count=1, return_type=0x0000000000000000, return_is_defined=false, return_is_tuple=false, calling_convention=ProcCC_Odin, original_type=0x00007fffecabb880) at llvm_abi.cpp:574:18
    frame #3: 0x0000555555741eee odin`lb_get_abi_info_internal(c=0x00005555559a2110, arg_types=0x00007fffecb73480, arg_count=1, return_type=0x0000000000000000, return_is_defined=false, return_is_tuple=false, calling_convention=ProcCC_Odin, original_type=0x00007fffecabb880) at llvm_abi.cpp:1511:11
    frame #4: 0x0000555555741170 odin`lb_get_abi_info(c=0x00005555559a2110, arg_types=0x00007fffecb73480, arg_count=1, return_type=0x0000000000000000, return_is_defined=false, return_is_tuple=false, calling_convention=ProcCC_Odin, original_type=0x00007fffecabb880) at llvm_abi.cpp:1531:23
    frame #5: 0x000055555573f351 odin`lb_type_internal_for_procedures_raw(m=0x00007fffecb69890, type=0x00007fffecabb880) at llvm_backend_general.cpp:1760:23
    frame #6: 0x000055555575380d odin`lb_get_procedure_raw_type(m=0x00007fffecb69890, type=0x00007fffecabb880) at llvm_backend_type.cpp:130:9
    frame #7: 0x0000555555751eed odin`lb_create_procedure(m=0x00007fffecb69890, entity=0x00007fffde4040d0, ignore_body=false) at llvm_backend_proc.cpp:132:26
    frame #8: 0x00005555557f7c33 odin`lb_generate_procedures_and_types_per_module(data=0x00007fffecb69890) at llvm_backend.cpp:1282:42
    frame #9: 0x0000555555735906 odin`lb_create_global_procedures_and_types(gen=0x00007fffecb697b0, info=0x00007fffeca2f0f8, do_threading=false) at llvm_backend.cpp:1345:4
    frame #10: 0x000055555559aac6 odin`lb_generate_code(gen=0x00007fffecb697b0) at llvm_backend.cpp:3295:2
    frame #11: 0x000055555557f522 odin`main(arg_count=4, arg_ptr=0x00007fffffffe0d8) at main.cpp:3025:7
    frame #12: 0x00007fffef839c88 libc.so.6`___lldb_unnamed_symbol3256 + 120
    frame #13: 0x00007fffef839d4c libc.so.6`__libc_start_main + 140
    frame #14: 0x0000555555569d75 odin`_start + 37

I also observe the same behavior with i128 as u128.

Kelimion commented 1 month ago

Confirmed on Ubuntu 24.04. Works as expected on Windows.