[llvm-dev] Return value from TargetLowering::LowerOperation?

Mikael Holmén via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 22 04:58:49 PST 2016


Hi,

I'm a litle bit puzzled by the TargetLowering::LowerOperation function, 
and what different callers of this function assumes about the returned 
value.

In several places it seems like it is assumed that LowerOperation can 
return three kinds of values:
* Something completely new.
* SDValue()
* The same SDValue as LowerOperation was called on.

However in some places, e.g. in TargetLowering::LowerOperationWrapper, 
it seems like it is assumed only the first two of the above cases can 
happen because there we do:

   SDValue Res = LowerOperation(SDValue(N, 0), DAG);
   if (Res.getNode())
     Results.push_back(Res);

So, when LowerOperationWrapper is called from 
DAGTypeLegalizer::CustomLowerNode, and my target's LowerOperation 
returns the same SDValue as it was called on since we don't want to do 
anything special with this particular SDValue, then we get an assert 
"Potential legalization loop!" when DAGTypeLegalizer::CustomLowerNode 
tries to replace the SDValue with itself.

So in some cases it's ok for LowerOperation to return the same SDValue 
it was called on, and sometimes it's not?

Can anyone shed some light on this?

Thanks,
Mikael


More information about the llvm-dev mailing list