Skip to content

Commit 1c1f1e6

Browse files
committed
LLVM: Handle intrinsic len more robustly
1 parent e41fa28 commit 1c1f1e6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,27 +3903,27 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
39033903
} else if (parent_subroutine){
39043904
push_nested_stack(parent_subroutine);
39053905
}
3906+
bool intrinsic_function = ASRUtils::is_intrinsic_function2(s);
39063907
uint32_t h;
3907-
if (s->m_abi == ASR::abiType::Source) {
3908+
if (s->m_abi == ASR::abiType::Source && !intrinsic_function) {
39083909
h = get_hash((ASR::asr_t*)s);
39093910
} else if (s->m_abi == ASR::abiType::LFortranModule) {
39103911
throw CodeGenError("Function LFortran interfaces not implemented yet");
39113912
} else if (s->m_abi == ASR::abiType::Interactive) {
39123913
h = get_hash((ASR::asr_t*)s);
3913-
} else if (s->m_abi == ASR::abiType::Intrinsic) {
3914+
} else if (s->m_abi == ASR::abiType::Intrinsic || intrinsic_function) {
39143915
std::string func_name = s->m_name;
39153916
if( fname2arg_type.find(func_name) != fname2arg_type.end() ) {
39163917
h = get_hash((ASR::asr_t*)s);
39173918
} else {
3919+
if (func_name == "len") {
3920+
std::vector<llvm::Value *> args = convert_call_args(x, "len");
3921+
LFORTRAN_ASSERT(args.size() == 1)
3922+
tmp = lfortran_str_len(args[0]);
3923+
return;
3924+
}
39183925
if( s->m_deftype == ASR::deftypeType::Interface ) {
3919-
if (func_name == "len") {
3920-
std::vector<llvm::Value *> args = convert_call_args(x, "len");
3921-
LFORTRAN_ASSERT(args.size() == 1)
3922-
tmp = lfortran_str_len(args[0]);
3923-
return;
3924-
} else {
3925-
throw CodeGenError("Intrinsic '" + func_name + "' not implemented yet and compile time value is not available.");
3926-
}
3926+
throw CodeGenError("Intrinsic '" + func_name + "' not implemented yet and compile time value is not available.");
39273927
} else {
39283928
h = get_hash((ASR::asr_t*)s);
39293929
}

0 commit comments

Comments
 (0)