@@ -111,8 +111,7 @@ CodeGenTypes::arrangeFreeFunctionType(CanQual<FunctionNoProtoType> FTNP) {
111
111
// When translating an unprototyped function type, always use a
112
112
// variadic type.
113
113
return arrangeLLVMFunctionInfo (FTNP->getReturnType ().getUnqualifiedType (),
114
- /* instanceMethod=*/ false ,
115
- /* chainCall=*/ false , std::nullopt,
114
+ FnInfoOpts::None, std::nullopt,
116
115
FTNP->getExtInfo (), {}, RequiredArgs (0 ));
117
116
}
118
117
@@ -188,10 +187,10 @@ arrangeLLVMFunctionInfo(CodeGenTypes &CGT, bool instanceMethod,
188
187
appendParameterTypes (CGT, prefix, paramInfos, FTP);
189
188
CanQualType resultType = FTP->getReturnType ().getUnqualifiedType ();
190
189
191
- return CGT. arrangeLLVMFunctionInfo (resultType, instanceMethod,
192
- /* chainCall= */ false , prefix,
193
- FTP-> getExtInfo (), paramInfos ,
194
- Required);
190
+ FnInfoOpts opts =
191
+ instanceMethod ? FnInfoOpts::IsInstanceMethod : FnInfoOpts::None;
192
+ return CGT. arrangeLLVMFunctionInfo (resultType, opts, prefix ,
193
+ FTP-> getExtInfo (), paramInfos, Required);
195
194
}
196
195
197
196
// / Arrange the argument and result information for a value of the
@@ -270,7 +269,7 @@ CodeGenTypes::arrangeCXXMethodType(const CXXRecordDecl *RD,
270
269
argTypes.push_back (DeriveThisType (RD, MD));
271
270
272
271
return ::arrangeLLVMFunctionInfo (
273
- *this , true , argTypes,
272
+ *this , /* instanceMethod= */ true , argTypes,
274
273
FTP->getCanonicalTypeUnqualified ().getAs <FunctionProtoType>());
275
274
}
276
275
@@ -362,9 +361,8 @@ CodeGenTypes::arrangeCXXStructorDeclaration(GlobalDecl GD) {
362
361
: TheCXXABI.hasMostDerivedReturn (GD)
363
362
? CGM.getContext ().VoidPtrTy
364
363
: Context.VoidTy ;
365
- return arrangeLLVMFunctionInfo (resultType, /* instanceMethod=*/ true ,
366
- /* chainCall=*/ false , argTypes, extInfo,
367
- paramInfos, required);
364
+ return arrangeLLVMFunctionInfo (resultType, FnInfoOpts::IsInstanceMethod,
365
+ argTypes, extInfo, paramInfos, required);
368
366
}
369
367
370
368
static SmallVector<CanQualType, 16 >
@@ -438,9 +436,9 @@ CodeGenTypes::arrangeCXXConstructorCall(const CallArgList &args,
438
436
addExtParameterInfosForCall (ParamInfos, FPT.getTypePtr (), TotalPrefixArgs,
439
437
ArgTypes.size ());
440
438
}
441
- return arrangeLLVMFunctionInfo (ResultType, /* instanceMethod= */ true ,
442
- /* chainCall= */ false , ArgTypes, Info ,
443
- ParamInfos, Required);
439
+
440
+ return arrangeLLVMFunctionInfo (ResultType, FnInfoOpts::IsInstanceMethod ,
441
+ ArgTypes, Info, ParamInfos, Required);
444
442
}
445
443
446
444
// / Arrange the argument and result information for the declaration or
@@ -459,10 +457,9 @@ CodeGenTypes::arrangeFunctionDeclaration(const FunctionDecl *FD) {
459
457
// When declaring a function without a prototype, always use a
460
458
// non-variadic type.
461
459
if (CanQual<FunctionNoProtoType> noProto = FTy.getAs <FunctionNoProtoType>()) {
462
- return arrangeLLVMFunctionInfo (
463
- noProto->getReturnType (), /* instanceMethod=*/ false ,
464
- /* chainCall=*/ false , std::nullopt, noProto->getExtInfo (), {},
465
- RequiredArgs::All);
460
+ return arrangeLLVMFunctionInfo (noProto->getReturnType (), FnInfoOpts::None,
461
+ std::nullopt, noProto->getExtInfo (), {},
462
+ RequiredArgs::All);
466
463
}
467
464
468
465
return arrangeFreeFunctionType (FTy.castAs <FunctionProtoType>());
@@ -511,9 +508,9 @@ CodeGenTypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
511
508
RequiredArgs required =
512
509
(MD->isVariadic () ? RequiredArgs (argTys.size ()) : RequiredArgs::All);
513
510
514
- return arrangeLLVMFunctionInfo (
515
- GetReturnType (MD-> getReturnType ()), /* instanceMethod= */ false ,
516
- /* chainCall= */ false , argTys, einfo, extParamInfos, required);
511
+ return arrangeLLVMFunctionInfo (GetReturnType (MD-> getReturnType ()),
512
+ FnInfoOpts::None, argTys, einfo, extParamInfos ,
513
+ required);
517
514
}
518
515
519
516
const CGFunctionInfo &
@@ -522,9 +519,8 @@ CodeGenTypes::arrangeUnprototypedObjCMessageSend(QualType returnType,
522
519
auto argTypes = getArgTypesForCall (Context, args);
523
520
FunctionType::ExtInfo einfo;
524
521
525
- return arrangeLLVMFunctionInfo (
526
- GetReturnType (returnType), /* instanceMethod=*/ false ,
527
- /* chainCall=*/ false , argTypes, einfo, {}, RequiredArgs::All);
522
+ return arrangeLLVMFunctionInfo (GetReturnType (returnType), FnInfoOpts::None,
523
+ argTypes, einfo, {}, RequiredArgs::All);
528
524
}
529
525
530
526
const CGFunctionInfo &
@@ -549,8 +545,7 @@ CodeGenTypes::arrangeUnprototypedMustTailThunk(const CXXMethodDecl *MD) {
549
545
assert (MD->isVirtual () && " only methods have thunks" );
550
546
CanQual<FunctionProtoType> FTP = GetFormalType (MD);
551
547
CanQualType ArgTys[] = {DeriveThisType (MD->getParent (), MD)};
552
- return arrangeLLVMFunctionInfo (Context.VoidTy , /* instanceMethod=*/ false ,
553
- /* chainCall=*/ false , ArgTys,
548
+ return arrangeLLVMFunctionInfo (Context.VoidTy , FnInfoOpts::None, ArgTys,
554
549
FTP->getExtInfo (), {}, RequiredArgs (1 ));
555
550
}
556
551
@@ -569,9 +564,8 @@ CodeGenTypes::arrangeMSCtorClosure(const CXXConstructorDecl *CD,
569
564
ArgTys.push_back (Context.IntTy );
570
565
CallingConv CC = Context.getDefaultCallingConvention (
571
566
/* IsVariadic=*/ false , /* IsCXXMethod=*/ true );
572
- return arrangeLLVMFunctionInfo (Context.VoidTy , /* instanceMethod=*/ true ,
573
- /* chainCall=*/ false , ArgTys,
574
- FunctionType::ExtInfo (CC), {},
567
+ return arrangeLLVMFunctionInfo (Context.VoidTy , FnInfoOpts::IsInstanceMethod,
568
+ ArgTys, FunctionType::ExtInfo (CC), {},
575
569
RequiredArgs::All);
576
570
}
577
571
@@ -615,10 +609,10 @@ arrangeFreeFunctionLikeCall(CodeGenTypes &CGT,
615
609
SmallVector<CanQualType, 16 > argTypes;
616
610
for (const auto &arg : args)
617
611
argTypes.push_back (CGT.getContext ().getCanonicalParamType (arg.Ty ));
612
+ FnInfoOpts opts = chainCall ? FnInfoOpts::IsChainCall : FnInfoOpts::None;
618
613
return CGT.arrangeLLVMFunctionInfo (GetReturnType (fnType->getReturnType ()),
619
- /* instanceMethod=*/ false , chainCall,
620
- argTypes, fnType->getExtInfo (), paramInfos,
621
- required);
614
+ opts, argTypes, fnType->getExtInfo (),
615
+ paramInfos, required);
622
616
}
623
617
624
618
// / Figure out the rules for calling a function with the given formal
@@ -649,8 +643,8 @@ CodeGenTypes::arrangeBlockFunctionDeclaration(const FunctionProtoType *proto,
649
643
auto argTypes = getArgTypesForDeclaration (Context, params);
650
644
651
645
return arrangeLLVMFunctionInfo (GetReturnType (proto->getReturnType ()),
652
- /* instanceMethod */ false , /* chainCall */ false ,
653
- argTypes, proto->getExtInfo (), paramInfos,
646
+ FnInfoOpts::None, argTypes ,
647
+ proto->getExtInfo (), paramInfos,
654
648
RequiredArgs::forPrototypePlus (proto, 1 ));
655
649
}
656
650
@@ -661,28 +655,27 @@ CodeGenTypes::arrangeBuiltinFunctionCall(QualType resultType,
661
655
SmallVector<CanQualType, 16 > argTypes;
662
656
for (const auto &Arg : args)
663
657
argTypes.push_back (Context.getCanonicalParamType (Arg.Ty ));
664
- return arrangeLLVMFunctionInfo (
665
- GetReturnType (resultType), /* instanceMethod=*/ false ,
666
- /* chainCall=*/ false , argTypes, FunctionType::ExtInfo (),
667
- /* paramInfos=*/ {}, RequiredArgs::All);
658
+ return arrangeLLVMFunctionInfo (GetReturnType (resultType), FnInfoOpts::None,
659
+ argTypes, FunctionType::ExtInfo (),
660
+ /* paramInfos=*/ {}, RequiredArgs::All);
668
661
}
669
662
670
663
const CGFunctionInfo &
671
664
CodeGenTypes::arrangeBuiltinFunctionDeclaration (QualType resultType,
672
665
const FunctionArgList &args) {
673
666
auto argTypes = getArgTypesForDeclaration (Context, args);
674
667
675
- return arrangeLLVMFunctionInfo (
676
- GetReturnType (resultType ), /* instanceMethod= */ false , /* chainCall= */ false ,
677
- argTypes, FunctionType::ExtInfo (), {}, RequiredArgs::All);
668
+ return arrangeLLVMFunctionInfo (GetReturnType (resultType), FnInfoOpts::None,
669
+ argTypes, FunctionType::ExtInfo ( ), {} ,
670
+ RequiredArgs::All);
678
671
}
679
672
680
673
const CGFunctionInfo &
681
674
CodeGenTypes::arrangeBuiltinFunctionDeclaration (CanQualType resultType,
682
675
ArrayRef<CanQualType> argTypes) {
683
- return arrangeLLVMFunctionInfo (
684
- resultType, /* instanceMethod= */ false , /* chainCall= */ false ,
685
- argTypes, FunctionType::ExtInfo (), {}, RequiredArgs::All);
676
+ return arrangeLLVMFunctionInfo (resultType, FnInfoOpts::None, argTypes,
677
+ FunctionType::ExtInfo (), {} ,
678
+ RequiredArgs::All);
686
679
}
687
680
688
681
// / Arrange a call to a C++ method, passing the given arguments.
@@ -705,15 +698,15 @@ CodeGenTypes::arrangeCXXMethodCall(const CallArgList &args,
705
698
auto argTypes = getArgTypesForCall (Context, args);
706
699
707
700
FunctionType::ExtInfo info = proto->getExtInfo ();
708
- return arrangeLLVMFunctionInfo (
709
- GetReturnType (proto-> getReturnType ()), /* instanceMethod= */ true ,
710
- /* chainCall= */ false , argTypes, info, paramInfos, required);
701
+ return arrangeLLVMFunctionInfo (GetReturnType (proto-> getReturnType ()),
702
+ FnInfoOpts::IsInstanceMethod, argTypes, info ,
703
+ paramInfos, required);
711
704
}
712
705
713
706
const CGFunctionInfo &CodeGenTypes::arrangeNullaryFunction () {
714
- return arrangeLLVMFunctionInfo (
715
- getContext (). VoidTy , /* instanceMethod= */ false , /* chainCall= */ false ,
716
- std::nullopt, FunctionType::ExtInfo (), {}, RequiredArgs::All);
707
+ return arrangeLLVMFunctionInfo (getContext (). VoidTy , FnInfoOpts::None,
708
+ std::nullopt, FunctionType::ExtInfo (), {} ,
709
+ RequiredArgs::All);
717
710
}
718
711
719
712
const CGFunctionInfo &
@@ -733,12 +726,15 @@ CodeGenTypes::arrangeCall(const CGFunctionInfo &signature,
733
726
auto argTypes = getArgTypesForCall (Context, args);
734
727
735
728
assert (signature.getRequiredArgs ().allowsOptionalArgs ());
736
- return arrangeLLVMFunctionInfo (signature.getReturnType (),
737
- signature.isInstanceMethod (),
738
- signature.isChainCall (),
739
- argTypes,
740
- signature.getExtInfo (),
741
- paramInfos,
729
+ FnInfoOpts opts = FnInfoOpts::None;
730
+ if (signature.isInstanceMethod ())
731
+ opts |= FnInfoOpts::IsInstanceMethod;
732
+ if (signature.isChainCall ())
733
+ opts |= FnInfoOpts::IsChainCall;
734
+ if (signature.isDelegateCall ())
735
+ opts |= FnInfoOpts::IsDelegateCall;
736
+ return arrangeLLVMFunctionInfo (signature.getReturnType (), opts, argTypes,
737
+ signature.getExtInfo (), paramInfos,
742
738
signature.getRequiredArgs ());
743
739
}
744
740
@@ -751,21 +747,24 @@ void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI);
751
747
// / Arrange the argument and result information for an abstract value
752
748
// / of a given function type. This is the method which all of the
753
749
// / above functions ultimately defer to.
754
- const CGFunctionInfo &
755
- CodeGenTypes::arrangeLLVMFunctionInfo (CanQualType resultType,
756
- bool instanceMethod,
757
- bool chainCall,
758
- ArrayRef<CanQualType> argTypes,
759
- FunctionType::ExtInfo info,
760
- ArrayRef<FunctionProtoType::ExtParameterInfo> paramInfos,
761
- RequiredArgs required) {
750
+ const CGFunctionInfo &CodeGenTypes::arrangeLLVMFunctionInfo (
751
+ CanQualType resultType, FnInfoOpts opts, ArrayRef<CanQualType> argTypes,
752
+ FunctionType::ExtInfo info,
753
+ ArrayRef<FunctionProtoType::ExtParameterInfo> paramInfos,
754
+ RequiredArgs required) {
762
755
assert (llvm::all_of (argTypes,
763
756
[](CanQualType T) { return T.isCanonicalAsParam (); }));
764
757
765
758
// Lookup or create unique function info.
766
759
llvm::FoldingSetNodeID ID;
767
- CGFunctionInfo::Profile (ID, instanceMethod, chainCall, info, paramInfos,
768
- required, resultType, argTypes);
760
+ bool isInstanceMethod =
761
+ (opts & FnInfoOpts::IsInstanceMethod) == FnInfoOpts::IsInstanceMethod;
762
+ bool isChainCall =
763
+ (opts & FnInfoOpts::IsChainCall) == FnInfoOpts::IsChainCall;
764
+ bool isDelegateCall =
765
+ (opts & FnInfoOpts::IsDelegateCall) == FnInfoOpts::IsDelegateCall;
766
+ CGFunctionInfo::Profile (ID, isInstanceMethod, isChainCall, isDelegateCall,
767
+ info, paramInfos, required, resultType, argTypes);
769
768
770
769
void *insertPos = nullptr ;
771
770
CGFunctionInfo *FI = FunctionInfos.FindNodeOrInsertPos (ID, insertPos);
@@ -775,8 +774,8 @@ CodeGenTypes::arrangeLLVMFunctionInfo(CanQualType resultType,
775
774
unsigned CC = ClangCallConvToLLVMCallConv (info.getCC ());
776
775
777
776
// Construct the function info. We co-allocate the ArgInfos.
778
- FI = CGFunctionInfo::create (CC, instanceMethod, chainCall, info ,
779
- paramInfos, resultType, argTypes, required);
777
+ FI = CGFunctionInfo::create (CC, isInstanceMethod, isChainCall, isDelegateCall ,
778
+ info, paramInfos, resultType, argTypes, required);
780
779
FunctionInfos.InsertNode (FI, insertPos);
781
780
782
781
bool inserted = FunctionsBeingProcessed.insert (FI).second ;
@@ -811,9 +810,8 @@ CodeGenTypes::arrangeLLVMFunctionInfo(CanQualType resultType,
811
810
return *FI;
812
811
}
813
812
814
- CGFunctionInfo *CGFunctionInfo::create (unsigned llvmCC,
815
- bool instanceMethod,
816
- bool chainCall,
813
+ CGFunctionInfo *CGFunctionInfo::create (unsigned llvmCC, bool instanceMethod,
814
+ bool chainCall, bool delegateCall,
817
815
const FunctionType::ExtInfo &info,
818
816
ArrayRef<ExtParameterInfo> paramInfos,
819
817
CanQualType resultType,
@@ -833,6 +831,7 @@ CGFunctionInfo *CGFunctionInfo::create(unsigned llvmCC,
833
831
FI->ASTCallingConvention = info.getCC ();
834
832
FI->InstanceMethod = instanceMethod;
835
833
FI->ChainCall = chainCall;
834
+ FI->DelegateCall = delegateCall;
836
835
FI->CmseNSCall = info.getCmseNSCall ();
837
836
FI->NoReturn = info.getNoReturn ();
838
837
FI->ReturnsRetained = info.getProducesResult ();
@@ -3985,10 +3984,6 @@ void CodeGenFunction::EmitDelegateCallArg(CallArgList &args,
3985
3984
3986
3985
QualType type = param->getType ();
3987
3986
3988
- if (isInAllocaArgument (CGM.getCXXABI (), type)) {
3989
- CGM.ErrorUnsupported (param, " forwarded non-trivially copyable parameter" );
3990
- }
3991
-
3992
3987
// GetAddrOfLocalVar returns a pointer-to-pointer for references,
3993
3988
// but the argument needs to be the original pointer.
3994
3989
if (type->isReferenceType ()) {
0 commit comments