[LLVMdev] Calls to functions with signext/zeroext return values

Cameron Zwarich zwarich at apple.com
Wed Mar 16 09:31:44 PDT 2011


On Mar 16, 2011, at 5:58 AM, Ken Dyck wrote:

> In SelectionDAGBuilder::visitRet(), there is this bit of code:
> 
>        // FIXME: C calling convention requires the return type to be promoted
>        // to at least 32-bit. But this is not necessary for non-C calling
>        // conventions. The frontend should mark functions whose return values
>        // require promoting with signext or zeroext attributes.
>        if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) {
>          EVT MinVT = TLI.getRegisterType(*DAG.getContext(), MVT::i32);
>          if (VT.bitsLT(MinVT))
>            VT = MinVT;
>        }
> 
> There have been a few discussions about this snippet on llvmdev in the
> past[1][2][3], and there seems to be a general consensus that the
> responsibility for promoting to the 'int' type should be transfered to
> the front end and the signext/zeroext attributes eliminated. But
> that's not what I'm interested in discussing here.
> 
> What I'd like to ask about is calls to functions that have a
> signext/zeroext attribute on their return value. As far as I can tell,
> there isn't any corresponding promotion of the return value to i32 in
> visitCall(). Should there be?

Promoting the return value is unsafe for bool returns on x86-64, which in the latest revision of the ABI only guarantees that the top 7 bits of the 8-bit register are 0.

Cameron



More information about the llvm-dev mailing list