Arnold Schwaighofer
2008-Jan-03 18:48 UTC
[LLVMdev] Tailcall optimization in jit stopped working
tailcall optimization stop working in jit (lli) in revision 45527. i guess this is because the jit is tailjmping to the wrong function address. the following change would reenable tailcallopt in jit. But i am pretty sure that this is not the correct fix (since i don't really understand what is going on :). maybe evan can comment on this? regards arnold Index: lib/Target/X86/X86CodeEmitter.cpp ==================================================================--- lib/Target/X86/X86CodeEmitter.cpp (revision 45541) +++ lib/Target/X86/X86CodeEmitter.cpp (working copy) @@ -601,7 +601,8 @@ if (MO.isMachineBasicBlock()) { emitPCRelativeBlockAddress(MO.getMBB()); } else if (MO.isGlobalAddress()) { - bool NeedStub = !IsStatic || + bool NeedStub = Opcode == X86::TAILJMPd || Opcode == X86::TAILJMPr || + Opcode == X86::TAILJMPm || !IsStatic || (Is64BitMode && TM.getCodeModel() == CodeModel::Large); emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word, 0, 0, NeedStub);
My bad. I'll fix it after I commit next batch of JIT changes. Evan On Jan 3, 2008, at 10:48 AM, Arnold Schwaighofer wrote:> tailcall optimization stop working in jit (lli) in revision 45527. i > guess this is because the jit is tailjmping to the wrong function > address. the following change would reenable tailcallopt in jit. But > i am pretty sure that this is not the correct fix (since i don't > really understand what is going on :). maybe evan can comment on this? > > regards arnold > > Index: lib/Target/X86/X86CodeEmitter.cpp > ==================================================================> --- lib/Target/X86/X86CodeEmitter.cpp (revision 45541) > +++ lib/Target/X86/X86CodeEmitter.cpp (working copy) > @@ -601,7 +601,8 @@ > if (MO.isMachineBasicBlock()) { > emitPCRelativeBlockAddress(MO.getMBB()); > } else if (MO.isGlobalAddress()) { > - bool NeedStub = !IsStatic || > + bool NeedStub = Opcode == X86::TAILJMPd || Opcode => X86::TAILJMPr || > + Opcode == X86::TAILJMPm || !IsStatic || > (Is64BitMode && TM.getCodeModel() == CodeModel::Large); > emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word, > 0, 0, NeedStub); > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi Arnold, http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of- Mon-20071231/056781.html Can you see if it's working for you now? Thanks, Evan On Jan 3, 2008, at 10:48 AM, Arnold Schwaighofer wrote:> tailcall optimization stop working in jit (lli) in revision 45527. i > guess this is because the jit is tailjmping to the wrong function > address. the following change would reenable tailcallopt in jit. But > i am pretty sure that this is not the correct fix (since i don't > really understand what is going on :). maybe evan can comment on this? > > regards arnold > > Index: lib/Target/X86/X86CodeEmitter.cpp > ==================================================================> --- lib/Target/X86/X86CodeEmitter.cpp (revision 45541) > +++ lib/Target/X86/X86CodeEmitter.cpp (working copy) > @@ -601,7 +601,8 @@ > if (MO.isMachineBasicBlock()) { > emitPCRelativeBlockAddress(MO.getMBB()); > } else if (MO.isGlobalAddress()) { > - bool NeedStub = !IsStatic || > + bool NeedStub = Opcode == X86::TAILJMPd || Opcode => X86::TAILJMPr || > + Opcode == X86::TAILJMPm || !IsStatic || > (Is64BitMode && TM.getCodeModel() == CodeModel::Large); > emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word, > 0, 0, NeedStub); > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Seemingly Similar Threads
- [LLVMdev] Why does the x86-64 JIT emit stubs for external calls?
- [LLVMdev] Why does the x86-64 JIT emit stubs for external calls?
- [LLVMdev] [unladen-swallow] Re: Why does the x86-64 JIT emit stubs for external calls?
- [LLVMdev] RFC: Tail call optimization X86
- [LLVMdev] Being able to know the jitted code-size before emitting