[LLVMdev] Tailcall optimization in jit stopped working

Arnold Schwaighofer arnold.schwaighofer at gmail.com
Thu Jan 3 10:48:26 PST 2008


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);




More information about the llvm-dev mailing list