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

Dale Johannesen dalej at apple.com
Fri Aug 27 12:13:06 PDT 2010

On Aug 27, 2010, at 11:53 AMPDT, Yuri wrote:

> On 08/27/2010 11:32, Yuri wrote:
>> As I understand only one of TCRETURNri64 and RET should be created.
>> I have sources of rev.112200.
>> Here is the stack when TCRETURNri64 instruction is created:
>> #1  0x0000000802c8b4e2 in llvm::MachineFunction::CreateMachineInstr
>> (this=0x30eb000, TID=@0x803a78940, DL={LineCol = 0, ScopeIdx = 0},
>> NoImp=false) at /tmp/llvm-svn/llvm/lib/CodeGen/MachineFunction.cpp: 
>> 153
>> #2  0x00000008028ea45b in llvm::BuildMI (BB=@0x4b69378,
>> I={<std::iterator<std::bidirectional_iterator_tag,  
>> llvm::MachineInstr,
>> long int, llvm::MachineInstr*, llvm::MachineInstr&>>  = {<No data
>> fields>}, NodePtr = 0x4b69440}, DL={LineCol = 0, ScopeIdx = 0},
>> TID=@0x803a78940) at MachineInstrBuilder.h:183
>> #3  0x0000000803451825 in llvm::X86RegisterInfo::emitPrologue
>> (this=0x1a96220, MF=@0x30eb000) at
>> /tmp/llvm-svn/llvm/lib/Target/X86/X86RegisterInfo.cpp:1037
> It seems wrong that TCRETURNri64 is created in  
> X86RegisterInfo::emitPrologue even when RET instruction is already  
> there. This seems to be a bug.

I don't think I believe this; emitPrologue should not be generating a  
TCRETURN at all, and line 1037 is generating a PROLOG_LABEL.  Why do  
you say it's a TCRETURN?

The way this is supposed to work:
SelectBasicBlock calls visit on the Call instruction, leading to  
  which winds up in X86TargetLowering::LowerCall:
which generates the TCRETURN and sets the isTailCall argument to True
which causes the loop in SelectBasicBlock to exit early, causing it to  
skip the RET.

It looks like the incoming RET (the Instruction, not the MachineInstr)  
is not getting skipped for some reason.  I suggest stepping through  
the path above to figure out why.

More information about the llvm-dev mailing list