GaloisInc / llvm-pretty

An llvm pretty printer inspired by the haskell llvm binding
Other
28 stars 15 forks source link

LLVM pretty produces an invalid `.ll` from rust-originated bitcode #15

Open TomMD opened 7 years ago

TomMD commented 7 years ago

Given the likely non-minimal rust:

pub fn f(x : i64) -> i32 {
    if x == 0 {
        return 1;
    } else {
        return 0;
   }
}

Observe:

$ rustc --emit llvm-bc --crate-type lib simple.rs -o simple.bc
$ llvm-disasm simple.bc > simple.ll
$ llc-3.8 simple.ll
llc-3.8: simple.ll:5:50: error: expected ')' at end of argument list
define i32 @_ZN6simple1f17hb796044fc140b16aE(i64 %0) {

The llvm-dis tool differs from llvm-disasm here:

llvm pretty (llvm-disasm):

define i32 @_ZN6simple1f17hb796044fc140b16aE(i64 %0) {
entry-block:
  %_0 = alloca i32, align 0
...

LLVM (llvm-dis):

define i32 @_ZN6simple1f17hb796044fc140b16aE(i64) unnamed_addr #0 {
entry-block:
  %_0 = alloca i32

So three things:

If I remove the %0 name and the align 0 then the llvm-disasm output does compile.