[LLVMdev] What does this error mean: psuedo instructions should be removed before code emission?

Dale Johannesen
Fri, 27 Aug 2010 18:05:47 -0000

On Aug 27, 2010, at 11:00 AMPDT, Eric Christopher wrote:
>>>
>>> For some reason I am getting this error even when I only have an
>>> empty 'main' function. So I couldn't create .ll file
reproducing
>>> it and I have to debug myself.
>>>
>>> The function causing the problem is stub created in
>>> JIT::runFunction: Function *Stub = Function::Create(STy,
>>> Function::InternalLinkage, "" ...
>>>
>>> Here is the log of machine instructions before and after
>>> emitEpilogue for this function:
>>> * PEI::insertPrologEpilogCode: === >> before emitEpilogue
>>> - insn: PUSH64r %RBP<kill>, %RSP<imp-def>,
%RSP<imp-use>
>>> - insn: PROLOG_LABEL <MCSym=.Ltmp2>
>>> - insn: %RBP<def> = MOV64rr %RSP
>>> - insn: PROLOG_LABEL <MCSym=.Ltmp3>
>>> - insn: %RDI<def> = MOV64ri64i32 60910096
>>> - insn: %RAX<def> = MOV64ri
>>> <ga:@_ZN010HelloWorld4mainEPN13ContainerSVecE>
>>> - insn: TCRETURNri64 %RAX<kill>, 0, %RDI<kill>,
%RAX<imp-
>>> def,dead>, %RDI<imp-def,dead>, %RSP<imp-use>, ...
>>> - insn: RET
>>> * PEI::insertPrologEpilogCode: === << before emitEpilogue
>>>
>>> Function only has on BB. Is this wrong that it has both
>>> TCRETURNri64 and RET in one BB?
>>
>> Yes, that is wrong.  The reason emitEpilogue isn't lowering the
>> TCRETURN is that it doesn't see it, it only sees the RET.   The
>> real problem will be where that RET is generated.   Normally that's
>> LowerCall (where it is spelled TC_RETURN), but reading through it I
>> can't see any way to generate both a TC_RETURN and a RET.
>>
> Bug somewhere for sure, but without a testcase or way to reproduce
> it then it'd be hard to find.

Yes, Yuri's going to have to debug it, or provide a way for others to
reproduce it.

It could be his host compiler is miscompiling llvm, too.