hashc icon indicating copy to clipboard operation
hashc copied to clipboard

Mismatching operand types (pointer to function) causes LLVM crash

Open feds01 opened this issue 10 months ago • 1 comments

The following snippet:

math := import("math")

// #dump_ir
main := () => {
    temp := Intrinsics::cast(type f64, type i32, -1.)
    t := math::abs(temp)
}

Causes the compiler to panic when dealing with abs argument with temp

Meta

Backtrace

Sorry :^(
Internal Compiler Error: Found PointerType(PointerType { ptr_type: Type { address: 0x7fab02816800, llvm_type: "ptr" } }) but expected the FunctionType variant

Occurred at '/Users/alex/.cargo/git/checkouts/inkwell-5052cb883294bc1f/58231ba/src/types/enums.rs:289:13'
Backtrace for thread "main":
   0: backtrace::backtrace::libunwind::trace
             at /Users/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5
      backtrace::backtrace::trace_unsynchronized
             at /Users/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5
   1: backtrace::backtrace::trace
             at /Users/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14
   2: backtrace::capture::Backtrace::create
             at /Users/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9
   3: backtrace::capture::Backtrace::new
             at /Users/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:140:22
   4: hash_utils::crash::crash_handler
             at compiler/hash-utils/src/crash.rs:53:25
   5: core::ops::function::Fn::call
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/core/src/ops/function.rs:79:5
   6: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/alloc/src/boxed.rs:2032:9
      std::panicking::rust_panic_with_hook
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panicking.rs:792:13
   7: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panicking.rs:657:13
   8: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/sys_common/backtrace.rs:171:18
   9: rust_begin_unwind
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panicking.rs:645:5
  10: core::panicking::panic_fmt
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/core/src/panicking.rs:72:14
  11: inkwell::types::enums::AnyTypeEnum::into_function_type
             at /Users/alex/.cargo/git/checkouts/inkwell-5052cb883294bc1f/58231ba/src/types/enums.rs:289:13
  12: hash_codegen_llvm::translation::builder::<impl hash_codegen::traits::builder::BlockBuilderMethods for hash_codegen_llvm::translation::LLVMBuilder>::call
             at compiler/hash-codegen-llvm/src/translation/builder.rs:226:23
  13: hash_codegen_llvm::translation::builder::<impl hash_codegen::traits::builder::BlockBuilderMethods for hash_codegen_llvm::translation::LLVMBuilder>::fp_to_int_sat
             at compiler/hash-codegen-llvm/src/translation/builder.rs:675:9
  14: hash_codegen::traits::builder::BlockBuilderMethods::float_to_int_cast
             at compiler/hash-codegen/src/traits/builder.rs:356:9
  15: hash_codegen::lower::rvalue::<impl hash_codegen::lower::FnBuilder<Builder>>::codegen_rvalue_operand
             at compiler/hash-codegen/src/lower/rvalue.rs:356:25
  16: hash_codegen::lower::statement::<impl hash_codegen::lower::FnBuilder<Builder>>::codegen_statement
             at compiler/hash-codegen/src/lower/statement.rs:24:43
  17: hash_codegen::lower::block::<impl hash_codegen::lower::FnBuilder<Builder>>::codegen_block
             at compiler/hash-codegen/src/lower/block.rs:61:17
  18: hash_codegen::lower::codegen_body
             at compiler/hash-codegen/src/lower/mod.rs:198:9
  19: hash_codegen_llvm::LLVMBackend::build_bodies
             at compiler/hash-codegen-llvm/src/lib.rs:298:13
  20: <hash_codegen_llvm::LLVMBackend as hash_codegen::backend::CompilerBackend>::run::{{closure}}
             at compiler/hash-codegen-llvm/src/lib.rs:341:37
  21: hash_utils::profiling::HasMutMetrics::record::{{closure}}
             at compiler/hash-utils/src/profiling.rs:111:16
  22: hash_utils::profiling::timed
             at compiler/hash-utils/src/profiling.rs:130:22
      hash_utils::profiling::HasMutMetrics::record
             at compiler/hash-utils/src/profiling.rs:110:21
  23: <hash_codegen_llvm::LLVMBackend as hash_codegen::backend::CompilerBackend>::run
             at compiler/hash-codegen-llvm/src/lib.rs:341:9
  24: <hash_backend::CodeGenPass as hash_pipeline::interface::CompilerStage<Ctx>>::run
             at compiler/hash-backend/src/lib.rs:68:9
  25: hash_driver::driver::Driver<I>::run_stage::{{closure}}
             at compiler/hash-driver/src/driver.rs:98:16
  26: hash_utils::profiling::timed
             at compiler/hash-utils/src/profiling.rs:130:22
      hash_driver::driver::Driver<I>::run_stage
             at compiler/hash-driver/src/driver.rs:97:9
  27: hash_driver::driver::Driver<I>::run_pipeline
             at compiler/hash-driver/src/driver.rs:159:26
  28: hash_driver::driver::Driver<I>::run
             at compiler/hash-driver/src/driver.rs:248:22
  29: hash_driver::driver::Driver<I>::run_filename
             at compiler/hash-driver/src/driver.rs:271:9
  30: hash_driver::driver::Driver<I>::run_on_entry_point
             at compiler/hash-driver/src/driver.rs:277:32
  31: hashc::main
             at compiler/hash/./src/main.rs:35:5
  32: core::ops::function::FnOnce::call_once
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/core/src/ops/function.rs:250:5
  33: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/sys_common/backtrace.rs:155:18
  34: std::rt::lang_start::{{closure}}
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/rt.rs:159:18
  35: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panic.rs:149:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/rt.rs:141:48
      std::panicking::try::do_call
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/panic.rs:149:14
      std::rt::lang_start_internal
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/rt.rs:141:20
  36: std::rt::lang_start
             at /rustc/1cec373f65eb76e8e4b4d1847213cf3ec6c292b6/library/std/src/rt.rs:158:17
  37: _main
  38: <unknown>

feds01 avatar Apr 23 '24 05:04 feds01