Andrew Haley
2009-Jan-21 12:15 UTC
[LLVMdev] Load from abs address generated bad code on LLVM 2.4
Chris Lattner wrote:> On Jan 20, 2009, at 2:10 AM, Andrew Haley wrote: > >> Chris Lattner wrote: >>> On Jan 19, 2009, at 7:55 AM, Andrew Haley wrote: >>> >>>> This is x86_64. I have a problem where an absolute memory load >>>> The current LLVM trunk does not have this bug. This seems quite a >>>> nasty >>>> bug; is there any chance of a bug-fix release for LLVM 2.4, or >>>> should I >>>> just use LLVM trunk until LLVM 2.5 ? >>> As others have pointed out, using a global and addglobalmapping is a >>> great workaround for the problem. >> Thanks. >> >>> We generally don't do "dot" releases, since we have a short release >>> cycle anyway. The 2.5 release process is slated to start this week. >> Mmm, but the problem is that interfaces keep changing, so simply >> upgrading to the latest release isn't possible. Even the tiny >> test case I posted doesn't work with the latest version: there >> were changes needed to get it to compile. Also, I can no longer >> figure out how to turn on debugging dumps in the JIT. The simple >> >> DebugFlag = true; >> CurrentDebugType = "x86-emitter"; >> >> no longer works, and there seems to be no replacement for it. > > 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. Andrew.
Chris Lattner
2009-Jan-21 18:07 UTC
[LLVMdev] Load from abs address generated bad code on LLVM 2.4
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, -Chris
Andrew Haley
2009-Jan-22 11:13 UTC
[LLVMdev] JIT debug dumps [Was Re: Load from abs address generated bad code on LLVM 2.4]
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.
Andrew Haley
2009-Jan-23 12:43 UTC
[LLVMdev] Load from abs address generated bad code on LLVM 2.4
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,Sadly, that doesn't work either. Well, it works once, but then you can't change it back. We need something more like --- ./lib/Support/Debug.cpp~ 2009-01-23 12:15:27.000000000 +0000 +++ lib/Support/Debug.cpp 2009-01-23 12:15:53.000000000 +0000 @@ -48,7 +48,7 @@ static cl::opt<DebugOnlyOpt, true, cl::parser<std::string> > DebugOnly("debug-only", cl::desc("Enable a specific type of debug output"), cl::Hidden, cl::value_desc("debug string"), - cl::location(DebugOnlyOptLoc), cl::ValueRequired); + cl::location(DebugOnlyOptLoc), cl::ValueRequired, cl::ZeroOrMore); #endif } to allow it to be dynamically used by a JIT. Of course, with a large program being JITted it's really important to be able just to use debugging exactly where you need it. Andrew.