Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LLVM: Fix visit_IfExp() #2271

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

Merged
merged 2 commits into from
Aug 12, 2023
Merged

LLVM: Fix visit_IfExp() #2271

merged 2 commits into from
Aug 12, 2023

Conversation

ubaidsk
Copy link
Collaborator

@ubaidsk ubaidsk commented Aug 12, 2023

fixes #2270

Copy link
Collaborator

@Smit-create Smit-create left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. First, we evaluate the condition, and then the correct block works. This might have been missed while we refactored and used create_if_else wherever possible.

@ubaidsk ubaidsk enabled auto-merge August 12, 2023 17:01
@ubaidsk ubaidsk merged commit 62fda8a into lcompilers:main Aug 12, 2023
@ubaidsk ubaidsk deleted the llvm_fix_ifexp branch August 12, 2023 17:03
return fib(n - 1) + fib(n - 2) if n >= 3 else 1

def main0():
res: i32 = fib(30)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shaikh-Ubaid BTW, just in case if you don't know, you can use less than fib(30) value (smaller). This is to make test run faster. Even for fib(10) there will be a crash of recursion overflow in older (unfixed) code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for sharing @polkovnikov! Yes, I agree fib(10) reproduces the error and could be faster that fib(30). I used fib(30), because:

  • the test case with fib(30) seems to execute quickly on my system
$ time python integration_tests/test_ifexp_03.py
832040
python integration_tests/test_ifexp_03.py  0.13s user 0.01s system 98% cpu 0.147 total
$ time lpython integration_tests/test_ifexp_03.py
832040
lpython integration_tests/test_ifexp_03.py  0.10s user 0.02s system 102% cpu 0.117 total
  • I think fib(30) might have much more recursion calls and therefore, huge stack space utilization due to it. Thus, I think the test also checks the working of the binary when there are many recursion calls and huge stack space utilization due to it.

Also thank you so much for trying LPython and reporting the bug! We appreciate it.

@certik
Copy link
Contributor

certik commented Aug 13, 2023

Awesome, thanks @Shaikh-Ubaid !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recursive call crashes program. Fibonacci simplest function
4 participants