14 ms·
I was just recently wondering if an LSTM neural net could be trained as a decent decompiler from LLVM IR to Rust source. Feed that with Clang output of an estab
by emailgregn 11y ago
I was just recently wondering if an LSTM neural net could be trained as a decent decompiler from LLVM IR to Rust source. Feed that with Clang output of an established OS and coreutils(i was thinking minix3 but maybe seL4) and get a working if not necessarily idiomatic Rust OS. Refactor at leisure.
- gaze 11y agoWhy would you ever do that? You'd end up a bunch of unreadable rust code wrapped in a gigantic unsafe {} block.
- emailgregn 11y agoThe LSTM would be trained against an existing high quality Rust code base and it's IR; so I wouldn't expect a bunch of unsafe literal translations. Whether the C side IR has enough debug metadata or could be annotated automatically would be the make or break.
- nickpsecurity 11y agoLike other commenter said, it would be unreadable. You'd be better off using a transformation system like Semantic Designs DMS or Stratego language with heuristics. Series of rules, analyses, and transforms applying until new code exists. Real problem with your scheme is that the typing and structure are important to effectively using Rust. Those that you get in LLVM will be nothing like what you would want in Rust and you'll need additional information. In other words, source to source with annotations is a better option.
- pshc 11y agoPerhaps unrealistic, but a brilliant concept.