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

Add flag to treat LLVM errors as fatal #77

Merged
merged 4 commits into from
Jul 25, 2023
Merged

Add flag to treat LLVM errors as fatal #77

merged 4 commits into from
Jul 25, 2023

Conversation

tamird
Copy link
Member

@tamird tamird commented Jul 21, 2023

This is apparently the contract we're supposed to uphold. Currently we sometimes miscompile things.

@tamird tamird force-pushed the rewrite-IR branch 2 times, most recently from 6624b7d to a732161 Compare July 21, 2023 17:31
@tamird tamird requested a review from ajwerner July 21, 2023 18:24
Copy link
Member

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

LGTM

src/llvm/mod.rs Outdated

LLVMPositionBuilderBefore(builder, instruction);
// Call instructions can't have a name; attempting to set one crashes LLVM.
let name = [0];
Copy link
Member

Choose a reason for hiding this comment

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

nit: it means the same thing but might be more obvious if you wrote this ['\0']

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be more obvious now.

src/llvm/mod.rs Outdated Show resolved Hide resolved
src/llvm/mod.rs Outdated

// Some debug info generated by rustc seems to trigger a segfault in the
// BTF code in llvm, so strip it until that is fixed
LLVMStripModuleDebugInfo(module);

// Collect up all the memory intrinsics. We're going to replace these with
Copy link
Member

Choose a reason for hiding this comment

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

nit: this whole thing to rewrite the memory intrinsics feels like it could belong in its own function.

Copy link
Member Author

Choose a reason for hiding this comment

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

It could. What does it get us? I'm not a fan of indirection for its own sake.

Copy link
Member

Choose a reason for hiding this comment

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

Ack. I think it can improve readability in so far as a human can summarize what the function does. By having the logic to do this rewriting inline, it becomes more difficult to internalize the code structure from a single pass. I am not religious here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is no longer in this PR.

.github/workflows/build-test.yml Outdated Show resolved Hide resolved
@alessandrod
Copy link
Collaborator

alessandrod commented Jul 22, 2023

I think adding the flag is good, but it should be disabled by default until the upstream LLVM conversation is resolved. I don't think we need to do the intrinsics => call change. The NewPM stuff should go in a separate PR.

Cargo.toml Outdated
debug = true

[patch.crates-io]
aya-rustc-llvm-proxy = { git = "https://github.com/aya-rs/rustc-llvm-proxy.git" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be removed before merging yeah?

Copy link
Member Author

Choose a reason for hiding this comment

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

You tell me - would you like to cut a release, or should we just take a git dep on the thing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Pulled this out of this PR.

@tamird
Copy link
Member Author

tamird commented Jul 24, 2023

I think adding the flag is good, but it should be disabled by default until the upstream LLVM conversation is resolved.

What's the resolution you're referring to? It seems that there's no way to not treat these errors as fatal and still avoid miscompilation.

I don't think we need to do the intrinsics => call change.

Are you suggesting we string match on that error and ignore it?

The NewPM stuff should go in a separate PR.

Sure, it will. I wanted to demonstrate that the IR rewriting change prevents the miscompilation that otherwise happens.

LLVM crashes happen relatively often during development, and we want to
be able to unwind through Rust when they do.
Move conversions to Rust strings out.
This flag is set to false by default while we figure out which errors
we see in practice.
Copy link
Member

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

LGTM

@tamird tamird merged commit 6814bc5 into main Jul 25, 2023
5 checks passed
@tamird tamird deleted the rewrite-IR branch July 25, 2023 22:26
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.

3 participants