[LLVMdev] JIT debug dumps [Was Re: Load from abs address generated bad code on LLVM 2.4]

Andrew Haley aph at redhat.com
Thu Jan 22 03:13:47 PST 2009


Chris Lattner wrote:
> On Jan 21, 2009, at 4:15 AM, Andrew Haley wrote:
>>> That should work fine, just use "jit" instead of "x86-emitter" as the
>>> debug type.
>> That's impossible: CurrentDebugType is now private; it appears
>> nowhere in the installed headers.  I can't find any public interface
>> to allow a JIT to set it.
> 
> Ah ok.  I'd suggest doing what llvm-gcc does here, it is a much more  
> stable API:
> 
>    std::vector<const char*> Args;
>    Args.push_back(""); // program name
>    Args.push_back("-debug-only=jit");
>    ...
>    Args.push_back(0);  // Null terminator.
>    cl::ParseCommandLineOptions(Args.size()-1, (char**)&Args[0]);
> 
> This also gives you control over optimizations and codegen options,

Yes, thanks.  It's a slightly weird hack, but it works perfectly.  :-)

"-debug-only=jit" generates just a binary dump, like this:

JIT: Binary code:
JIT: 00000000: 4a04b848 000000ca 048b0000 c320

whereas "-debug-only=x86-emitter" generates this:

%RAX<def> = MOV64ri <ga:poo1>
%EAX<def> = MOV32rm %RAX<kill>, 1, %reg0, 0, Mem:LD(4,4) [poo1 + 0]
RET %EAX<imp-use,kill>

which may be more useful.

Can I put in a request some machine-independent names for the debug
dumps?  It's "x86-emitter", "alpha-emitter", "x86-codegen", and so on.
We'd have to put a big target-dependent switch statement in our code to
enable asm dumps.

Andrew.



More information about the llvm-dev mailing list