Rust for LLVM fixing?

I have heard that Rust can be faster than C/C++ but is slower in some cases due to LLVM bugs. My question is, can LLVM parts be rewritten in Rust directly, in case those bugs can be fixed?

In a purely theoretical sense, yes.

In practice, it will depend on the policies of the LLVM maintainers, and I don’t know that any of them frequent this forum. You’ll have better luck asking this question of the LLVM project itself instead of here.

I'm not sure if I follow this. Bugs in LLVM which could result in slowdown are AFAIK logic bugs, not the safety ones, so Rust code will likely contain them too, unless someone fixes it (and it might be easier to fix the currently existing C++, then to rewrite in Rust).

4 Likes

↑ This.


One would have to design a domain-specific programming language, that is made for transforming assembly, performing only logically correct transformations, otherwise throwing compilation errors. It'd be great, if such a language existed, but it doesn't and we're stuck with programming languages like C and Rust for this task, none of which are particular helpful in this domain.

Imagine, SQL didn't exist and all developers had to deal with a C API to work with databases. That pretty accurately describes the current state of LLVM.

The problematic bugs in LLVM are not memory safety bugs, but incorrect logic. And while Rust is helpful, it can't solve things like the IR being insufficiently rigorously defined to even know what transformations are legal.

The core problem is that if you're generating assembly code, the memory- or thread-safety of the language in which you do it really can't help materially in generating that code correctly.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.