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

Invalid LLVM generated #4475

Closed
SeanTAllen opened this issue Dec 27, 2023 · 1 comment · Fixed by #4506
Closed

Invalid LLVM generated #4475

SeanTAllen opened this issue Dec 27, 2023 · 1 comment · Fixed by #4506
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@SeanTAllen
Copy link
Member

class Foo
  new create(a: U32) ? =>
    error

actor Main
  new create(env: Env) =>
    try
      let f = Foo(1)?
    end

Results in:

Terminator found in the middle of a basic block!
label %entry
Error:
Module verification failed: Terminator found in the middle of a basic block!
label %entry
@SeanTAllen SeanTAllen added help wanted Extra attention is needed bug Something isn't working needs investigation This needs to be looked into before its "ready for work" labels Dec 27, 2023
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Dec 27, 2023
@SeanTAllen
Copy link
Member Author

SeanTAllen commented Dec 27, 2023

I think the most reasonable thing for this given that

class Foo
  new create(a: U32) ? =>
    if a > 10 then
      error
    end
    
actor Main
  new create(env: Env) =>
    try
      let f = Foo(1)?
    end

is valid code, is to verify that a constructor can actually construct an object given some path through it. That is the assumption that I believe leads to the bad LLVM. We should be catching the "this can only error" and reporting back as that as something that needs to be fixed.

@SeanTAllen SeanTAllen added good first issue Good for newcomers and removed needs investigation This needs to be looked into before its "ready for work" discuss during sync Should be discussed during an upcoming sync labels Jan 9, 2024
ArthurPV added a commit to ArthurPV/ponyc that referenced this issue Apr 17, 2024
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Apr 17, 2024
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Apr 18, 2024
jemc pushed a commit that referenced this issue Apr 30, 2024
Fix #4475

Before this change, `LLVM` reported an error during module verification when trying to compile the code referenced in issue #4475:

```pony
class Foo
  new create(a: U32) ? =>
    error

actor Main
  new create(env: Env) =>
    try
      let f = Foo(1)?
    end
```
This bug was caused by the failure to check for the presence of terminator instructions when generating `ret` instructions. So now, with this change, there's a check for the absence of a terminator instruction each time a `ret` instruction is generated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants