Switch all of the indirect-call code in IRGen to FunctionPointer.

To make this stick, I've disallowed direct use of that overload of
CreateCall.  I've left the Constant overloads available, but eventually
we might want to consider fixing those, too, just to get all of this
code out of the business of manually remembering to pass around
attributes and calling conventions.

The test changes reflect the fact that we weren't really setting
attributes consistently at all, in this case on value witnesses.
This commit is contained in:
John McCall
2017-07-28 22:17:07 -04:00
parent 3c7af4eaf3
commit a0f20f673d
37 changed files with 473 additions and 463 deletions

View File

@@ -15,6 +15,7 @@
//
//===----------------------------------------------------------------------===//
#include "Callee.h"
#include "ConstantBuilder.h"
#include "Explosion.h"
#include "GenClass.h"
@@ -72,7 +73,7 @@ getAccessorForComputedComponent(IRGenModule &IGM,
if (requirements.empty()) {
return accessorFn;
}
auto accessorFnTy = accessorFn->getType()->getPointerElementType();
// Otherwise, we need a thunk to unmarshal the generic environment from the
@@ -142,9 +143,9 @@ getAccessorForComputedComponent(IRGenModule &IGM,
forwardingSubs,
&witnessMetadata,
forwardedArgs);
auto call = IGF.Builder.CreateCall(accessorFn, forwardedArgs.claimAll());
if (whichAccessor == Getter)
call->addAttribute(1, llvm::Attribute::StructRet);
auto fnPtr = FunctionPointer::forDirect(IGM, accessorFn,
accessor->getLoweredFunctionType());
IGF.Builder.CreateCall(fnPtr, forwardedArgs.claimAll());
IGF.Builder.CreateRetVoid();
}