[LLVMdev] Request for merge: GHC/ARM calling convention.

Duncan Sands baldrick at free.fr
Fri Oct 14 08:22:47 PDT 2011


Hi Karel,

>>> > const unsigned*
>>> > ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF)
>>> const {
>>> > + bool ghcCall = false;
>>> > +
>>> > + if (MF) {
>>> > + const Function *F = MF->getFunction();
>>> > + ghcCall = (F ? F->getCallingConv() == CallingConv::GHC : false);
>>> > + }
>>>
>>> > This bit looks dubious. Why do you need to do it?
>>>
>>> What exactly? We need to test if this is GHC calling convention or not
>>> and if
>>> its, then return different set of callee saved regs. What exactly
>>> don't you like
>>> on this piece?
>>
>> I don't see anyone else rummaging around inside the original function
>> for the
>> calling convention, so why do you need to?
>
> Based on knowledge of calling convention we return different set of callee saved
> registers. For example on ARM and when GHC CC is used, we return empty set.

yeah, but here MF is (presumably) the callee.  The callee shouldn't be relevant
to how arguments are marshalled at the call-site.  Especially as there might not
even be a callee function (case of an indirect call).  Since calls themselves
are annotated with the calling convention to use, I guess the calling convention
should be grabbed from the call instruction itself somehow.

>
>> If this information is useful to
>> have, why isn't it in the machine function?
>
> Honestly speaking, I don't know. The code in question is not written by me, but
> IMHO the motivation was just to get job done and allow later someone with better
> knowledge of LLVM internals to do required refactoring -- if you are pointing on
> the fact why we have not refactored calling convention call from Function to
> MachineFuction yet.

If it's because MF is represents the callee then it hasn't been done because
using it would almost certainly be wrong I guess :(

Ciao, Duncan.



More information about the llvm-dev mailing list