GaloisInc / llvm-pretty

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

Pretty printing `call` is broken for ppLLVM38 #11

Closed TomMD closed 7 years ago

TomMD commented 7 years ago

I have a rather simple test case:

int test(int x) { return f(x); } // Not legal C99 w/o extern decl for `f` but it is accepted by Clang

Observe:

% clang -emit-llvm -c so.c -o so.bc
% cat so.ll
...
  %3 = call i32 (i32, ...) bitcast (i32 (...)* @f to i32 (i32, ...)*)(i32 %2)
...

So that's what LLVM 3.8 produced. What do we produce?

Right bc <- parseBitCodeFromFile "so.bc"
writeFile "trevors.ll" (show $ ppLLVM38 $ ppModule bc)
... cat that file and splice....
  %3 = call i32(i32, ...)* bitcast (i32(...)* @f to i32(i32,...)*)(i32 %2)

Notice the excess * in the section argument.

LLVM 3.8 says about this argument:

‘fnty‘: shall be the signature of the pointer to function value being invoked. The argument types must match the types implied by this signature. This type can be omitted if the function is not varargs and if the function type does not return a pointer to a function.

TomMD commented 7 years ago

Oh, I guess I have permissions to this repository for better or worse. I just pushed eef9858 which fixes this. However, since I intended to push to my fork and make a merge request I'l leave this ticket open as a stand-in for that process.