Tail calls through function pointers should work.If not please send a testcase. I just added the two examples from the bug (1392) that calls for true tail call support. They work on my machine (-tailcallopt needs to be enabled) ;) That would be commit 56127. regards On Thu, Sep 11, 2008 at 11:21 PM, Evan Cheng <evan.cheng at apple.com> wrote:> Arnold implemented tail call. We should all urge him to continue his work to > make it even better. :-) > > Evan > > On Sep 9, 2008, at 1:19 AM, OvermindDL1 wrote: > >>> Tail calls are disabled by default; to enable them, you have to pass >>> -tailcallopt to llc. It looks like there's a bug preventing indirect >>> tail calls from working... I don't think there's anything >>> fundamentally preventing them from working, though. >> >> I will not be using llc, it will all be through the C++ API. I looked >> through the code a bit, but could not see any real direct way to turn >> on tall-calls, the only thing I could really find was a single global >> (yes, a global... ugh...) that many things referenced, if I set that >> then things should use tail-call versions of things. >> >> What about this indirect bug, is anyone working on it? I would try, >> but I am quite certain I do not yet have the LLVM internals knowledge >> to (or even where to look). >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
On Thu, Sep 11, 2008 at 4:31 PM, Arnold Schwaighofer <arnold.schwaighofer at gmail.com> wrote:> Tail calls through function pointers should work.If not please send a testcase. > > I just added the two examples from the bug (1392) that calls for true > tail call support. They work on my machine (-tailcallopt needs to be > enabled) ;) > > That would be commit 56127. > > regardsQuick question, how do you enable tail calls for the JIT when using the API, not an external app; in my program it is all internal, nothing external is called and the only thing I saw was that one global on a quick look through.
I'm trying to implement *MUL_LOHI for my processor. My processor has mulxss (e.g.) that gives the 32 high bits of a 64 bit multiply. I tried this in ios2ISelDAGToDAG.cpp: /// Mul/Div with two results case ISD::SMUL_LOHI: case ISD::UMUL_LOHI: { SDValue Op1 = Node->getOperand(0); SDValue Op2 = Node->getOperand(1); AddToISelQueue(Op1); AddToISelQueue(Op2); unsigned Op; Op = (Opcode == ISD::UMUL_LOHI ? Nios2::MULxu : Nios2::MULx); SDNode *Hi = CurDAG->getTargetNode(Op, MVT::Flag, Op1, Op2); SDNode *Lo = CurDAG->getTargetNode(Nios2::MUL, MVT::Flag, Op1, Op2); if (!N.getValue(0).use_empty()) ReplaceUses(N.getValue(0), SDValue(Lo,0)); if (!N.getValue(1).use_empty()) ReplaceUses(N.getValue(1), SDValue(Hi,0)); return NULL; } The code generator complains: nios2-elf-ecc: /home/rich/llvm-trunk-new/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:141: void llvm::ScheduleDAG::BuildSchedUnits(): Assertion `N->getNodeId() == -1 && "Node already inserted!"' failed I'm guessing that's because I'm reusing Op1 and Op2. What is the right way to reuse DAG operands? -Rich
For marking a call site as a tail call you have to call void setTailCall(bool isTC = true) on the CallInst. The calling convention of the function needs to be CallingConv::Fast (currently only fastcc calls are optimized) and the call has to be in tail position of course. To enable tail call optimization in an embedded vm i guess you would include llvm/Target/TargetOptions.h and set the static variable PerformTailCallOpt to true. Take this with a grain of salt or two since i have never done it ;) but i guess that setting those globals is what cl::ParseCommandLineOptions does in lli/llc.cpp. regards arnold> Quick question, how do you enable tail calls for the JIT when using > the API, not an external app; in my program it is all internal, > nothing external is called and the only thing I saw was that one > global on a quick look through. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >