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

bfc hangs due to compile-time evaluation #28

Open
BambooL opened this issue Jun 24, 2019 · 4 comments
Open

bfc hangs due to compile-time evaluation #28

BambooL opened this issue Jun 24, 2019 · 4 comments

Comments

@BambooL
Copy link

BambooL commented Jun 24, 2019

I am trying to compile the following code with bfc -O2:
. + [[ [[ >. [+ [<>]]] >]<>+ .]>< ,-.,,+++[]---]

But it shows warning:

24852.bf:1:26 warning: This instruction moves the pointer after the last cell (99999), to cell 100000.
  . + [[ [[ >. [+ [<>]]] >]<>+ .]>< ,-.,,+++[]---]
                         ^

But no exit. It should fall into some infinite loop or similar things.

@BambooL
Copy link
Author

BambooL commented Jun 25, 2019

Another similar problem is also found when compiling:

-[+ >>>.><-[--<]-->.+.--],[><--[.]-]- [] >>- <-,>,

it shows the warning but the compilation is not stopping.

Wilfred added a commit that referenced this issue Jun 25, 2019
@Wilfred Wilfred changed the title Compilation no return bfc hangs during compile-time evaluation Jun 25, 2019
@Wilfred Wilfred changed the title bfc hangs during compile-time evaluation bfc hangs due to compile-time evaluation Jun 26, 2019
@Wilfred
Copy link
Owner

Wilfred commented Jun 26, 2019

This looks like an issue where we aggressively unroll the loop due to compile-time evaluation, send a huge amount of IR to LLVM, and then it spends ages trying to optimise the IR.

I've added an undocumented BFC_MAX_STEPS which limits the execution steps and thus the LLVM IR size. Nonetheless, execution steps are still fast, it's the IR munging afterwards that's taking the time.

Possibly related: #26.

@BambooL
Copy link
Author

BambooL commented Jun 26, 2019

Since the issue is addressed by the owner. I will close this thread.

@BambooL BambooL closed this as completed Jun 26, 2019
@Wilfred
Copy link
Owner

Wilfred commented Jun 30, 2019

I think this a genuine bug worth fixing, so I'm going to reopen this :)

@Wilfred Wilfred reopened this Jun 30, 2019
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

No branches or pull requests

2 participants