Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Assertion failed in fgMorphCall #2073

Closed
MichalStrehovsky opened this issue Oct 24, 2016 · 7 comments
Closed

Assertion failed in fgMorphCall #2073

MichalStrehovsky opened this issue Oct 24, 2016 · 7 comments
Assignees
Labels

Comments

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Oct 24, 2016

In CoreCLR, canTailCall is hardcoded to return false in Ready To Run compilation - we never attempt to do tail calls. The CoreRT compiler doesn't put such restrictions and we're hitting the following assert when compiling Hello world with CHK RyuJIT (the combination of R2R and tail calls allowed triggers this):

#ifdef DEBUG
        // Tail call needs to be in one of the following IR forms
        //    Either a call stmt or
        //    GT_RETURN(GT_CALL(..)) or
        //    var = call
        noway_assert((stmtExpr->gtOper == GT_CALL && stmtExpr == call) ||
                     (stmtExpr->gtOper == GT_RETURN &&
                      (stmtExpr->gtOp.gtOp1 == call || stmtExpr->gtOp.gtOp1->gtOp.gtOp1 == call)) ||
                     (stmtExpr->gtOper == GT_ASG && stmtExpr->gtOp.gtOp2 == call));
#endif

To repro, undo the workaround from #2074.

@jkotas scoped the problem down to an issue around FEATURE_TAILCALL_OPT_SHARED_RETURN

MichalStrehovsky added a commit to MichalStrehovsky/corert that referenced this issue Oct 24, 2016
@MichalStrehovsky
Copy link
Member Author

@sandreenko We have a workaround that unblocks CoreRT for now, but we might hit this in other code.

@sandreenko
Copy link

Ok, I will try to fix it before tomorrow.

@MichalStrehovsky
Copy link
Member Author

(I was trying to imply it's not urgent and there's no need to drop what you're working on right now. Just put it close to the top of the queue :).)

@sandreenko
Copy link

@sivarv please take a look.

               [000029] --CXG-------             /--*  cast      int <- bool <- void
               [000026] --CXG-------             |  \--*  call ind  void
               [000023] ------------ arg0        |     +--*  lclVar    ref    V05 loc2
               [000024] ------------ arg1        |     +--*  lclVar    ref    V04 loc1
               [000025] ------------ calli tgt   |     \--*  lclVar    long   V03 loc0
               [000031] -A--G-------             *  =         int
               [000030] D----+-N----             \--*  lclVar    int    V07 tmp0

Is it correct tail call tree or not?

@sivarv
Copy link
Member

sivarv commented Oct 27, 2016

@sandreenko - It doesn't look like a valid tail call tree that RyuJIt supports as per fgMorphCall() assert.

What is even more suspicious is that call returns void and we have a cast from void to int! I think investigating that will lead us to the actual issue here.

@sandreenko
Copy link

It should be cast from int to bool to int, but we force call return type to void for all tail calls during morph phase.

        // As we will actually call CORINFO_HELP_TAILCALL, set the callTyp to TYP_VOID.
        // to avoid doing any extra work for the return value.
        call->gtType = TYP_VOID;

@sivarv
Copy link
Member

sivarv commented Oct 27, 2016

Please send me the full jitdump of the method by e-mail.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants