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

Fix bug preventing access to formal parameters in addition to variables #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heksterb
Copy link

@heksterb heksterb commented Apr 1, 2022

The code as provided is missing some parts that deal with accessing parameters (as opposed to variables). To demonstrate, run

$ ./build/tools/driver/tinylang --emit-llvm examples/Gcd.mod

and view the generated examples/Gcd.ll. Note specifically the while.cond block does not have instructions for the two assignments to parameters a and b. Before my changes:

while.cond:                                       ; preds = %while.body, %after.if
  %1 = icmp ne i64 %b, 0
  br i1 %1, label %while.body, label %after.while

With my changes:

while.cond:                                       ; preds = %while.body, %after.if
  %1 = phi i64 [ %2, %while.body ], [ %a, %after.if ]
  %2 = phi i64 [ %4, %while.body ], [ %b, %after.if ]
  %3 = icmp ne i64 %2, 0
  br i1 %3, label %while.body, label %after.while

Also verified with a test program that the generated function produces the correct numerical result.

Copy link

@OrchidRock OrchidRock left a comment

Choose a reason for hiding this comment

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

CR Ok!

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

Successfully merging this pull request may close these issues.

None yet

2 participants