-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
FIX: segfault in string handling #3003
Conversation
a74250c
to
b91e433
Compare
SciPy failure MRE: SUBROUTINE PRINI()
CHARACTER *1 MES(1)
RETURN
ENTRY PRIN(MES)
RETURN
END % lfortran a.f90
style suggestion: Use character(1) instead of character*1
--> a.f90:3:1
|
3 | CHARACTER *1 MES(1)
| ^^^^^^^^^^^^ help: write this as 'character(1)'
ASR verify pass error: ASR verify: Array type in pointer must have deferred shape
--> a.f90:3:1
|
3 | CHARACTER *1 MES(1)
| ^^^^^^^^^^^^^^^^^^^ failed here
Note: Please report unclear or confusing messages as bugs at
https://github.com/lfortran/lfortran/issues. |
I have made progress over this, I get code generation error now: % lfortran a.f90 --show-llvm --no-warnings
; ModuleID = 'LFortran'
source_filename = "LFortran"
%array = type { i8**, i32, %dimension_descriptor*, i1, i32 }
%dimension_descriptor = type { i32, i32, i32 }
define void @prin([1 x i8*] %mes) {
.entry:
%call_arg_value = alloca i32, align 4
store i32 2, i32* %call_arg_value, align 4
call void @prini_main__lcompilers(i32* %call_arg_value, [1 x i8*] %mes)
br label %return
return: ; preds = %.entry
ret void
}
define void @prini() {
.entry:
%call_arg_value = alloca i32, align 4
%mes = alloca %array*, align 8
store %array* null, %array** %mes, align 8
%arr_desc = alloca %array, align 8
%0 = getelementptr %array, %array* %arr_desc, i32 0, i32 2
%1 = alloca i32, align 4
store i32 1, i32* %1, align 4
%2 = load i32, i32* %1, align 4
%3 = alloca %dimension_descriptor, i32 %2, align 8
store %dimension_descriptor* %3, %dimension_descriptor** %0, align 8
%4 = getelementptr %array, %array* %arr_desc, i32 0, i32 4
store i32 1, i32* %4, align 4
%5 = getelementptr %array, %array* %arr_desc, i32 0, i32 0
store i8** null, i8*** %5, align 8
store %array* %arr_desc, %array** %mes, align 8
store i32 1, i32* %call_arg_value, align 4
%6 = load %array*, %array** %mes, align 8
call void @prini_main__lcompilers(i32* %call_arg_value, %array* %6)
br label %return
return: ; preds = %.entry
ret void
}
define void @prini_main__lcompilers(i32* %entry__lcompilers, [1 x i8*] %mes) {
.entry:
%0 = load i32, i32* %entry__lcompilers, align 4
%1 = icmp eq i32 %0, 1
br i1 %1, label %then, label %else
then: ; preds = %.entry
br label %goto_target
unreachable_after_goto: ; No predecessors!
br label %ifcont
else: ; preds = %.entry
br label %ifcont
ifcont: ; preds = %else, %unreachable_after_goto
%2 = load i32, i32* %entry__lcompilers, align 4
%3 = icmp eq i32 %2, 2
br i1 %3, label %then1, label %else3
then1: ; preds = %ifcont
br label %goto_target5
unreachable_after_goto2: ; No predecessors!
br label %ifcont4
else3: ; preds = %ifcont
br label %ifcont4
ifcont4: ; preds = %else3, %unreachable_after_goto2
br label %goto_target
goto_target: ; preds = %ifcont4, %then
br label %return
unreachable_after_return: ; No predecessors!
br label %goto_target5
goto_target5: ; preds = %unreachable_after_return, %then1
br label %return
unreachable_after_return6: ; No predecessors!
br label %return
return: ; preds = %unreachable_after_return6, %goto_target5, %goto_target
ret void
}
code generation error: asr_to_llvm: module failed verification. Error:
Call parameter type does not match function signature!
%6 = load %array*, %array** %mes, align 8
[1 x i8*] call void @prini_main__lcompilers(i32* %call_arg_value, %array* %6)
Note: Please report unclear or confusing messages as bugs at
https://github.com/lfortran/lfortran/issues. |
The above one is fixed, next we have is: SUBROUTINE PRINI()
CHARACTER *1 MES(1)
RETURN
ENTRY PRIN(MES)
CALL MESSPR(MES)
RETURN
END % lfortran a.f90 --show-llvm --implicit-typing --implicit-interface
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
File "/Users/pranavchiku/repos/lfortran/src/bin/lfortran.cpp", line 2254
return emit_llvm(arg_file, lfortran_pass_manager,
File "/Users/pranavchiku/repos/lfortran/src/bin/lfortran.cpp", line 847
= fe.get_llvm(input, lm, pass_manager, diagnostics);
File "/Users/pranavchiku/repos/lfortran/src/lfortran/fortran_evaluator.cpp", line 292
Result<std::unique_ptr<LLVMModule>> res = get_llvm2(code, lm, pass_manager, diagnostics);
File "/Users/pranavchiku/repos/lfortran/src/lfortran/fortran_evaluator.cpp", line 314
diagnostics, lm.files.back().in_filename);
File "/Users/pranavchiku/repos/lfortran/src/lfortran/fortran_evaluator.cpp", line 360
compiler_options, run_fn, infile);
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 9441
} catch (const CodeGenError &e) {
File "../libasr/asr.h", line 5059
File "../libasr/asr.h", line 5035
File "../libasr/asr.h", line 5060
File "../libasr/asr.h", line 4768
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 938
visit_symbol(*item.second);
File "../libasr/asr.h", line 5062
File "../libasr/asr.h", line 4777
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 3713
visit_procedures(x);
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 3910
this->visit_stmt(*x.m_body[i]);
File "../libasr/asr.h", line 5079
File "../libasr/asr.h", line 4827
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 8511
args.insert(args.end(), args2.begin(), args2.end());
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 7995
} else {
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 5142
if( x->type == ASR::exprType::ArrayItem ||
File "../libasr/asr.h", line 5126
File "../libasr/asr.h", line 4934
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 5078
}
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 5049
tmp = llvm_utils->create_gep(tmp, 0);
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/llvm_array_utils.cpp", line 535
return llvm_utils->create_gep(arr, 0);
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/llvm_utils.cpp", line 1360
return LLVM::CreateGEP(*builder, ds, idx_vec);
File "/Users/pranavchiku/repos/lfortran/src/libasr/codegen/llvm_utils.cpp", line 25
LCOMPILERS_ASSERT(t->isPointerTy());
AssertFailed: t->isPointerTy()
|
Perfect. Let me know if you need help. |
I am not sure how to fix #3003 (comment), I am wrapping up today's work, will push to get it fixed by tomorrow. |
Damnn! CI looks good, 🤞🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. Thanks @Pranavchiku !
@czgdp1807 can you please also review this before we merge it?
Fixes: #2997.
TODO: