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

Return statements inside basic blocks #8

Open
Sh3b0 opened this issue Mar 6, 2022 · 0 comments
Open

Return statements inside basic blocks #8

Sh3b0 opened this issue Mar 6, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@Sh3b0
Copy link
Owner

Sh3b0 commented Mar 6, 2022

Code to reproduce

routine power(number : integer, to_power : integer) : integer is
	var tmp is 1;
	if to_power < 1 then
		return 1;
	end
	for i in 0 .. to_power - 1 loop
		tmp := tmp * number;
	end
	return tmp;
end

routine main(input : integer) is 
	println power(2, 3);
	return;
end

Expected behavior

Prints 8

Actual behavior

[LLVM]: [WARNINGS]:
Terminator found in the middle of a basic block!
label %then

ir.ll:38:3: error: instruction expected to be numbered '%1'
  %0 = load i64, i64* %tmp
  ^
1 error generated.
Error generating IR

Comments

  • Return statements inside basic basic blocks (if/else label, for loop) always produce that warning, sometimes the program still work, but it's better to invistigate that issue as it might be the root cause.
  • Related question
@Sh3b0 Sh3b0 added the bug Something isn't working label Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant