8000 `move_alloc` throws code gen error · Issue #3838 · lfortran/lfortran · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
move_alloc throws code gen error #3838
Closed
@HarshitaKalani

Description

@HarshitaKalani
program test_move_alloc
  integer, allocatable :: a(:), b(:)
  allocate(a(3))
  a = [ 1, 2, 3 ]
  call move_alloc(a, b)
  print *, allocated(a), allocated(b)
  print *, b
end program test_move_alloc
$ gfortran a.f90 && ./a.out
 F T
           1           2           3
$ lfortran a.f90 
; ModuleID = 'LFortran'
source_filename = "LFortran"

%array = type { i32*, i32, %dimension_descriptor*, i1, i32 }
%dimension_descriptor = type { i32, i32, i32 }

@0 = private unnamed_addr constant [2 x i8] c" \00", align 1
@1 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@2 = private unnamed_addr constant [6 x i8] c"False\00", align 1
@3 = private unnamed_addr constant [5 x i8] c"True\00", align 1
@4 = private unnamed_addr constant [6 x i8] c"False\00", align 1
@5 = private unnamed_addr constant [5 x i8] c"True\00", align 1
@6 = private unnamed_addr constant [9 x i8] c"%s%s%s%s\00", align 1
@7 = private unnamed_addr constant [2 x i8] c" \00", align 1
@8 = private unnamed_addr constant [2 x i8] c" \00", align 1
@9 = private unnamed_addr constant [5 x i8] c"%d%s\00", align 1
@10 = private unnamed_addr constant [2 x i8] c" \00", align 1
@11 = private unnamed_addr constant [2 x i8] c"\08\00", align 1
@12 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@13 = private unnamed_addr constant [2 x i8] c" \00", align 1
@14 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@15 = private unnamed_addr constant [3 x i8] c"%s\00", align 1

declare void @__module_lfortran_intrinsic_builtin_move_alloc(i32**, i32**)

define i32 @main(i32 %0, i8** %1) {
.entry:
  %array_bound2 = alloca i32, align 4
  %array_bound = alloca i32, align 4
  call void @_lpython_call_initial_functions(i32 %0, i8** %1)
  %__1_k = alloca i32, align 4
  %__1_t = alloca i32, align 4
  %__1_v = alloca i32, align 4
  %__libasr__created__var__0__array_constant_ = alloca [3 x i32], align 4
  %a = alloca %array*, align 8
  store %array* null, %array** %a, align 8
  %arr_desc = alloca %array, align 8
  %2 = getelementptr %array, %array* %arr_desc, i32 0, i32 2
  %3 = alloca i32, align 4
  store i32 1, i32* %3, align 4
  %4 = load i32, i32* %3, align 4
  %5 = alloca %dimension_descriptor, i32 %4, align 8
  store %dimension_descriptor* %5, %dimension_descriptor** %2, align 8
  %6 = getelementptr %array, %array* %arr_desc, i32 0, i32 4
  store i32 1, i32* %6, align 4
  %7 = getelementptr %array, %array* %arr_desc, i32 0, i32 0
  store i32* null, i32** %7, align 8
  store %array* %arr_desc, %array** %a, align 8
  %b = alloca %array*, align 8
  store %array* null, %array** %b, align 8
  %arr_desc1 = alloca %array, align 8
  %8 = getelementptr %array, %array* %arr_desc1, i32 0, i32 2
  %9 = alloca i32, align 4
  store i32 1, i32* %9, align 4
  %10 = load i32, i32* %9, align 4
  %11 = alloca %dimension_descriptor, i32 %10, align 8
  store %dimension_descriptor* %11, %dimension_descriptor** %8, align 8
  %12 = getelementptr %array, %array* %arr_desc1, i32 0, i32 4
  store i32 1, i32* %12, align 4
  %13 = getelementptr %array, %array* %arr_desc1, i32 0, i32 0
  store i32* null, i32** %13, align 8
  store %array* %arr_desc1, %array** %b, align 8
  %14 = load %array*, %array** %a, align 8
  %15 = getelementptr %array, %array* %14, i32 0, i32 1
  store i32 0, i32* %15, align 4
  %16 = getelementptr %array, %array* %14, i32 0, i32 2
  %17 = load %dimension_descriptor*, %dimension_descriptor** %16, align 8
  %18 = getelementptr inbounds %dimension_descriptor, %dimension_descriptor* %17, i32 0
  %19 = getelementptr %dimension_descriptor, %dimension_descriptor* %18, i32 0, i32 0
  %20 = getelementptr %dimension_descriptor, %dimension_descriptor* %18, i32 0, i32 1
  %21 = getelementptr %dimension_descriptor, %dimension_descriptor* %18, i32 0, i32 2
  store i32 1, i32* %19, align 4
  store i32 1, i32* %20, align 4
  store i32 3, i32* %21, align 4
  %22 = getelementptr %array, %array* %14, i32 0, i32 0
  %23 = alloca i32, align 4
  store i32 12, i32* %23, align 4
  %24 = load i32, i32* %23, align 4
  %25 = call i8* (i32, ...) @_lfortran_malloc(i32 %24)
  %26 = bitcast i8* %25 to i32*
  store i32* %26, i32** %22, align 8
  br i1 true, label %then, label %else

then:                                             ; preds = %.entry
  store i32 1, i32* %array_bound, align 4
  br label %ifcont

else:                                             ; preds = %.entry
  br label %ifcont

ifcont:                                           ; preds = %else, %then
  %27 = load i32, i32* %array_bound, align 4
  store i32 %27, i32* %__1_k, align 4
  %28 = load i32, i32* %__1_k, align 4
  %29 = sub i32 %28, 1
  %30 = mul i32 1, %29
  %31 = add i32 0, %30
  %32 = getelementptr [3 x i32], [3 x i32]* %__libasr__created__var__0__array_constant_, i32 0, i32 %31
  store i32 1, i32* %32, align 4
  %33 = load i32, i32* %__1_k, align 4
  %34 = add i32 %33, 1
  store i32 %34, i32* %__1_k, align 4
  %35 = load i32, i32* %__1_k, align 4
  %36 = sub i32 %35, 1
  %37 = mul i32 1, %36
  %38 = add i32 0, %37
  %39 = getelementptr [3 x i32], [3 x i32]* %__libasr__created__var__0__array_constant_, i32 0, i32 %38
  store i32 2, i32* %39, align 4
  %40 = load i32, i32* %__1_k, align 4
  %41 = add i32 %40, 1
  store i32 %41, i32* %__1_k, align 4
  %42 = load i32, i32* %__1_k, align 4
  %43 = sub i32 %42, 1
  %44 = mul i32 1, %43
  %45 = add i32 0, %44
  %46 = getelementptr [3 x i32], [3 x i32]* %__libasr__created__var__0__array_constant_, i32 0, i32 %45
  store i32 3, i32* %46, align 4
  %47 = load i32, i32* %__1_k, align 4
  %48 = add i32 %47, 1
  store i32 %48, i32* %__1_k, align 4
  br i1 true, label %then3, label %else4

then3:                                            ; preds = %ifcont
  store i32 1, i32* %array_bound2, align 4
  br label %ifcont5

else4:                                            ; preds = %ifcont
  br label %ifcont5

ifcont5:                                          ; preds = %else4, %then3
  %49 = load i32, i32* %array_bound2, align 4
  store i32 %49, i32* %__1_v, align 4
  %50 = load %array*, %array** %a, align 8
  %51 = getelementptr %array, %array* %50, i32 0, i32 2
  %52 = load %dimension_descriptor*, %dimension_descriptor** %51, align 8
  %53 = getelementptr inbounds %dimension_descriptor, %dimension_descriptor* %52, i32 0
  %54 = getelementptr %dimension_descriptor, %dimension_descriptor* %53, i32 0, i32 1
  %55 = load i32, i32* %54, align 4
  %56 = sub i32 %55, 1
  store i32 %56, i32* %__1_t, align 4
  br label %loop.head

loop.head:                                        ; preds = %loop.body, %ifcont5
  %57 = load i32, i32* %__1_t, align 4
  %58 = add i32 %57, 1
  %59 = load %array*, %array** %a, align 8
  %60 = getelementptr %array, %array* %59, i32 0, i32 2
  %61 = load %dimension_descriptor*, %dimension_descriptor** %60, align 8
  %62 = getelementptr inbounds %dimension_descriptor, %dimension_descriptor* %61, i32 0
  %63 = getelementptr %dimension_descriptor, %dimension_descriptor* %62, i32 0, i32 1
  %64 = load i32, i32* %63, align 4
  %65 = getelementptr %dimension_descriptor, %dimension_descriptor* %62, i32 0, i32 2
  %66 = load i32, i32* %65, align 4
  %67 = add i32 %66, %64
  %68 = sub i32 %67, 1
  %69 = icmp sle i32 %58, %68
  br i1 %69, label %loop.body, label %loop.end

loop.body:                                        ; preds = %loop.head
  %70 = load i32, i32* %__1_t, align 4
  %71 = add i32 %70, 1
  store i32 %71, i32* %__1_t, align 4
  %72 = load i32, i32* %__1_t, align 4
  %73 = load %array*, %array** %a, align 8
  %74 = getelementptr %array, %array* %73, i32 0, i32 2
  %75 = load %dimension_descriptor*, %dimension_descriptor** %74, align 8
  %76 = getelementptr inbounds %dimension_descriptor, %dimension_descriptor* %75, i32 0
  %77 = getelementptr %dimension_descriptor, %dimension_descriptor* %76, i32 0, i32 1
  %78 = load i32, i32* %77, align 4
  %79 = sub i32 %72, %78
  %80 = getelementptr %dimension_descriptor, %dimension_descriptor* %76, i32 0, i32 0
  %81 = load i32, i32* %80, align 4
  %82 = mul i32 %81, %79
  %83 = add i32 0, %82
  %84 = getelementptr %array, %array* %73, i32 0, i32 1
  %85 = load i32, i32* %84, align 4
  %86 = add i32 %83, %85
  %87 = getelementptr %array, %array* %73, i32 0, i32 0
  %88 = load i32*, i32** %87, align 8
  %89 = getelementptr inbounds i32, i32* %88, i32 %86
  %90 = load i32, i32* %__1_v, align 4
  %91 = sub i32 %90, 1
  %92 = mul i32 1, %91
  %93 = add i32 0, %92
  %94 = getelementptr [3 x i32], [3 x i32]* %__libasr__created__var__0__array_constant_, i32 0, i32 %93
  %95 = load i32, i32* %94, align 4
  store i32 %95, i32* %89, align 4
  %96 = load i32, i32* %__1_v, align 4
  %97 = add i32 %96, 1
  store i32 %97, i32* %__1_v, align 4
  br label %loop.head

loop.end:                                         ; preds = %loop.head
  %98 = load %array*, %array** %b, align 8
  %99 = getelementptr %array, %array* %98, i32 0, i32 0
  %100 = load i32*, i32** %99, align 8
  %101 = ptrtoint i32* %100 to i64
  %102 = icmp ne i64 %101, 0
  br i1 %102, label %then6, label %else7

then6:                                            ; preds = %loop.end
  %103 = getelementptr %array, %array* %98, i32 0, i32 0
  %104 = load i32*, i32** %103, align 8
  %105 = alloca i8*, align 8
  %106 = bitcast i32* %104 to i8*
  store i8* %106, i8** %105, align 8
  %107 = load i8*, i8** %105, align 8
  call void (i8*, ...) @_lfortran_free(i8* %107)
  %108 = getelementptr %array, %array* %98, i32 0, i32 0
  store i32* null, i32** %108, align 8
  br label %ifcont8

else7:                                            ; preds = %loop.end
  br label %ifcont8

ifcont8:                                          ; preds = %else7, %then6
  call void @__module_lfortran_intrinsic_builtin_move_alloc(%array** %a, %array** %b)
  %109 = load %array*, %array** %a, align 8
  %110 = getelementptr %array, %array* %109, i32 0, i32 0
  %111 = load i32*, i32** %110, align 8
  %112 = ptrtoint i32* %111 to i64
  %113 = icmp ne i64 %112, 0
  %114 = icmp eq i1 %113, false
  %115 = select i1 %114, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @3, i32 0, i32 0)
  %116 = load %array*, %array** %b, align 8
  %117 = getelementptr %array, %array* %116, i32 0, i32 0
  %118 = load i32*, i32** %117, align 8
  %119 = ptrtoint i32* %118 to i64
  %120 = icmp ne i64 %119, 0
  %121 = icmp eq i1 %120, false
  %122 = select i1 %121, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @5, i32 0, i32 0)
  call void (i8*, ...) @_lfortran_printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @6, i32 0, i32 0), i8* %115, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i8* %122, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @1, i32 0, i32 0))
  %123 = load %array*, %array** %b, align 8
  %124 = getelementptr %array, %array* %123, i32 0, i32 2
  %125 = load %dimension_descriptor*, %dimension_descriptor** %124, align 8
  %126 = getelementptr inbounds %dimension_descriptor, %dimension_descriptor* %125, i32 0
  %127 = getelementptr %dimension_descriptor, %dimension_descriptor* %126, i32 0, i32 1
  %128 = load i32, i32* %127, align 4
  %129 = sub i32 %128, 1
  store i32 %129, i32* %__1_k, align 4
  br label %loop.head9

loop.head9:                                       ; preds = %loop.body10, %ifcont8
  %130 = load i32, i32* %__1_k, align 4
  %131 = add i32 %130, 1
  %132 = load %array*, %array** %b, align 8
  %133 = getelementptr %array, %array* %132, i32 0, i32 2
  %134 = load %dimension_descriptor*, %dimension_descriptor** %133, align 8
  %135 = getelementptr inbounds %dimension_descriptor, %dimension_descriptor* %134, i32 0
  %136 = getelementptr %dimension_descriptor, %dimension_descriptor* %135, i32 0, i32 1
  %137 = load i32, i32* %136, align 4
  %138 = getelementptr %dimension_descriptor, %dimension_descriptor* %135, i32 0, i32 2
  %139 = load i32, i32* %138, align 4
  %140 = add i32 %139, %137
  %141 = sub i32 %140, 1
  %142 = icmp sle i32 %131, %141
  br i1 %142, label %loop.body10, label %loop.end11

loop.body10:                                      ; preds = %loop.head9
  %143 = load i32, i32* %__1_k, align 4
  %144 = add i32 %143, 1
  store i32 %144, i32* %__1_k, align 4
  %145 = load i32, i32* %__1_k, align 4
  %146 = load %array*, %array** %b, align 8
  %147 = getelementptr %array, %array* %146, i32 0, i32 2
  %148 = load %dimension_descriptor*, %dimension_descriptor** %147, align 8
  %149 = getelementptr inbounds %dimension_descriptor, %dimension_descriptor* %148, i32 0
  %150 = getelementptr %dimension_descriptor, %dimension_descriptor* %149, i32 0, i32 1
  %151 = load i32, i32* %150, align 4
  %152 = sub i32 %145, %151
  %153 = getelementptr %dimension_descriptor, %dimension_descriptor* %149, i32 0, i32 0
  %154 = load i32, i32* %153, align 4
  %155 = mul i32 %154, %152
  %156 = add i32 0, %155
  %157 = getelementptr %array, %array* %146, i32 0, i32 1
  %158 = load i32, i32* %157, align 4
  %159 = add i32 %156, %158
  %160 = getelementptr %array, %array* %146, i32 0, i32 0
  %161 = load i32*, i32** %160, align 8
  %162 = getelementptr inbounds i32, i32* %161, i32 %159
  %163 = load i32, i32* %162, align 4
  call void (i8*, ...) @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @9, i32 0, i32 0), i32 %163, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @8, i32 0, i32 0))
  br label %loop.head9

loop.end11:                                       ; preds = %loop.head9
  call void (i8*, ...) @_lfortran_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @12, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @11, i32 0, i32 0))
  call void (i8*, ...) @_lfortran_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @15, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @14, i32 0, i32 0))
  %164 = load %array*, %array** %a, align 8
  %165 = getelementptr %array, %array* %164, i32 0, i32 0
  %166 = load i32*, i32** %165, align 8
  %167 = ptrtoint i32* %166 to i64
  %168 = icmp ne i64 %167, 0
  br i1 %168, label %then12, label %else13

then12:                                           ; preds = %loop.end11
  %169 = getelementptr %array, %array* %164, i32 0, i32 0
  %170 = load i32*, i32** %169, align 8
  %171 = alloca i8*, align 8
  %172 = bitcast i32* %170 to i8*
  store i8* %172, i8** %171, align 8
  %173 = load i8*, i8** %171, align 8
  call void (i8*, ...) @_lfortran_free(i8* %173)
  %174 = getelementptr %array, %array* %164, i32 0, i32 0
  store i32* null, i32** %174, align 8
  br label %ifcont14

else13:                                           ; preds = %loop.end11
  br label %ifcont14

ifcont14:                                         ; preds = %else13, %then12
  %175 = load %array*, %array** %b, align 8
  %176 = getelementptr %array, %array* %175, i32 0, i32 0
  %177 = load i32*, i32** %176, align 8
  %178 = ptrtoint i32* %177 to i64
  %179 = icmp ne i64 %178, 0
  br i1 %179, label %then15, label %else16

then15:                                           ; preds = %ifcont14
  %180 = getelementptr %array, %array* %175, i32 0, i32 0
  %181 = load i32*, i32** %180, align 8
  %182 = alloca i8*, align 8
  %183 = bitcast i32* %181 to i8*
  store i8* %183, i8** %182, align 8
  %184 = load i8*, i8** %182, align 8
  call void (i8*, ...) @_lfortran_free(i8* %184)
  %185 = getelementptr %array, %array* %175, i32 0, i32 0
  store i32* null, i32** %185, align 8
  br label %ifcont17

else16:                                           ; preds = %ifcont14
  br label %ifcont17

ifcont17:                                         ; preds = %else16, %then15
  %186 = load %array*, %array** %a, align 8
  %187 = getelementptr %array, %array* %186, i32 0, i32 0
  %188 = load i32*, i32** %187, align 8
  %189 = ptrtoint i32* %188 to i64
  %190 = icmp ne i64 %189, 0
  br i1 %190, label %then18, label %else19

then18:                                           ; preds = %ifcont17
  %191 = getelementptr %array, %array* %186, i32 0, i32 0
  %192 = load i32*, i32** %191, align 8
  %193 = alloca i8*, align 8
  %194 = bitcast i32* %192 to i8*
  store i8* %194, i8** %193, align 8
  %195 = load i8*, i8** %193, align 8
  call void (i8*, ...) @_lfortran_free(i8* %195)
  %196 = getelementptr %array, %array* %186, i32 0, i32 0
  store i32* null, i32** %196, align 8
  br label %ifcont20

else19:                                           ; preds = %ifcont17
  br label %ifcont20

ifcont20:                                         ; preds = %else19, %then18
  %197 = load %array*, %array** %b, align 8
  %198 = getelementptr %array, %array* %197, i32 0, i32 0
  %199 = load i32*, i32** %198, align 8
  %200 = ptrtoint i32* %199 to i64
  %201 = icmp ne i64 %200, 0
  br i1 %201, label %then21, label %else22

then21:                                           ; preds = %ifcont20
  %202 = getelementptr %array, %array* %197, i32 0, i32 0
  %203 = load i32*, i32** %202, align 8
  %204 = alloca i8*, align 8
  %205 = bitcast i32* %203 to i8*
  store i8* %205, i8** %204, align 8
  %206 = load i8*, i8** %204, align 8
  call void (i8*, ...) @_lfortran_free(i8* %206)
  %207 = getelementptr %array, %array* %197, i32 0, i32 0
  store i32* null, i32** %207, align 8
  br label %ifcont23

else22:                                           ; preds = %ifcont20
  br label %ifcont23

ifcont23:                                         ; preds = %else22, %then21
  ret i32 0
}

declare void @_lpython_call_initial_functions(i32, i8**)

declare i8* @_lfortran_malloc(i32, ...)

declare void @_lfortran_free(i8*, ...)

declare void @_lfortran_printf(i8*, ...)
asr_to_llvm: module failed verification. Error:
Call parameter type does not match function signature!
  %a = alloca %array*, align 8
 i32**  call void @__module_lfortran_intrinsic_builtin_move_alloc(%array** %a, %array** %b)

code generation error: asr_to_llvm: module failed verification. Error:
Call parameter type does not match function signature!
  %a = alloca %array*, align 8
 i32**  call void @__module_lfortran_intrinsic_builtin_move_alloc(%array** %a, %array** %b)



Note: Please report unclear, confusing or incorrect messages as bugs at
https://github.com/lfortran/lfortran/issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0