[PATCH] D25204: Register Calling Convention, Clang changes

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 4 09:38:44 PDT 2016


rnk added inline comments.


> AttrDocs.td:1263
> +On x86 targets, this attribute changes the calling convention to
> +__regcall convention. This convention aimes to pass as many arguments
> +as possible in registers. It also tries to utilize registers for the

"aims"

> TargetInfo.cpp:3306
> +  // Sum up bases
> +  if (auto CXXRD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
> +    for (const auto &I : CXXRD->bases())

You might want to defend against dynamic C++ records which will have vtable fields.

> TargetInfo.cpp:3323
> +      unsigned localNeededInt, localNeededSSE;
> +      if (classifyArgumentType(FD->getType(), (std::numeric_limits<unsigned>::max)(),
> +                                    localNeededInt, localNeededSSE, true).isIndirect()) {

This code doesn't need to worry about windows.h defining max.

> TargetInfo.cpp:3388-3389
>  
> -    unsigned neededInt, neededSSE;
> -    it->info = classifyArgumentType(it->type, freeIntRegs, neededInt,
> +    if (IsRegCall && it->type->isStructureType())
> +    {
> +      it->info = classifyRegCallStructType(it->type, neededInt, neededSSE);

not llvm style

> TargetInfo.cpp:3742-3743
>  
> -  // We can use up to 6 SSE register parameters with vectorcall.
> -  FreeSSERegs = IsVectorCall ? 6 : 0;
> +  // Regcall doesn't differentiate between return and parameter registers,
> +  // and non Reg/Vector call was 0 anyway.
> +  if (IsVectorCall) {

'classify' takes FreeSSERegs by reference and modifies it, so are you sure this is correct? It means if I have this kind of prototype, we won't pass 'd' in registers because we'll consume four registers for the return value:

  struct HFA { __m128 f[4]; };
  HFA __regcall f(HFA a, HFA b, HFA c, HFA d) {
    ...
  }

> SemaDecl.cpp:8288
>          int DiagID =
> -            CC == CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
> +            (CC == CC_X86StdCall || CC == CC_X86RegCall) ? diag::warn_cconv_knr : diag::err_cconv_knr;
>          Diag(NewFD->getLocation(), DiagID)

The comment doesn't apply here. Are you sure you don't want some other behavior, like unprototyped functions are actually implicitly void when regcall is used, as in C++?

https://reviews.llvm.org/D25204





More information about the cfe-commits mailing list