Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM code gen failed duo to #soa dynamic array element getting cleared with {} #4277

Open
LeoBlute opened this issue Sep 20, 2024 · 0 comments
Labels

Comments

@LeoBlute
Copy link

Odin:    dev-2024-09:c1264c2a7
OS:      Ubuntu 22.04.5 LTS, Linux 6.8.8-060808-generic
CPU:     AMD Ryzen 3 2200G with Radeon Vega Graphics    
RAM:     13889 MiB
Backend: LLVM 14.0.0

If a element of dynamic array with the #soa attribute is cleared using {}, The compiler, or llvm, will fail to generate the proper code, instead, will throw a LLVM CODE GEN FAILED, only happens with dynamic arrays,

Example:

package main

large_integer :: struct {
   low_part: i32,
   hight_part: i32
}

main :: proc() {
   arr : #soa[dynamic]large_integer
   arr[0] = {}
   /*for &elem in arr {
      elem = {}
   }*/
}

Throws:

LLVM CODE GEN FAILED FOR PROCEDURE: main.main
define internal void @main.main(i8* noalias nocapture nonnull %__.context_ptr) {
decls:
  %arr = alloca { i32*, i32*, i64, i64, %runtime.Allocator }, align 8
  br label %entry

entry:                                            ; preds = %decls
  %0 = bitcast i8* %__.context_ptr to %runtime.Context*
  %1 = bitcast { i32*, i32*, i64, i64, %runtime.Allocator }* %arr to i8*
  call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 48, i1 false)
  %2 = getelementptr inbounds { i32*, i32*, i64, i64, %runtime.Allocator }, { i32*, i32*, i64, i64, %runtime.Allocator }* %arr, i32 0, i32 2
  %3 = load i64, i64* %2, align 8
  call void @runtime.bounds_check_error(%..string { i8* getelementptr inbounds ([56 x i8], [56 x i8]* @"csbs$aa", i64 0, i64 0), i64 55 }, i32 10, i32 8, i64 0, i64 %3)
  %4 = getelementptr inbounds { i32*, i32*, i64, i64, %runtime.Allocator }, { i32*, i32*, i64, i64, %runtime.Allocator }* %arr, i32 0, i32 0
  %5 = load i32*, i32** %4, align 8
  %6 = getelementptr i32, i32* %5, i64 0
  store i32* null, i32* %6, align 8
  %7 = getelementptr inbounds { i32*, i32*, i64, i64, %runtime.Allocator }, { i32*, i32*, i64, i64, %runtime.Allocator }* %arr, i32 0, i32 1
  %8 = load i32*, i32** %7, align 8
  %9 = getelementptr i32, i32* %8, i64 0
  store i32* null, i32* %9, align 8
  ret void
}




Stored value type does not match pointer operand type!
  store i32* null, i32* %6, align 8
 i32*Stored value type does not match pointer operand type!
  store i32* null, i32* %9, align 8
@laytan laytan added the bug label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants