@@ -499,7 +499,8 @@ CodeGenTypes::arrangeCXXConstructorCall(const CallArgList &args,
499499// / Arrange the argument and result information for the declaration or
500500// / definition of the given function.
501501const CGFunctionInfo &
502- CodeGenTypes::arrangeFunctionDeclaration (const FunctionDecl *FD) {
502+ CodeGenTypes::arrangeFunctionDeclaration (const GlobalDecl GD) {
503+ const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl ());
503504 if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
504505 if (MD->isImplicitObjectMemberFunction ())
505506 return arrangeCXXMethodDeclaration (MD);
@@ -509,6 +510,13 @@ CodeGenTypes::arrangeFunctionDeclaration(const FunctionDecl *FD) {
509510 assert (isa<FunctionType>(FTy));
510511 setCUDAKernelCallingConvention (FTy, CGM, FD);
511512
513+ if (FD->hasAttr <OpenCLKernelAttr>() &&
514+ GD.getKernelReferenceKind () == KernelReferenceKind::Stub) {
515+ const FunctionType *FT = FTy->getAs <FunctionType>();
516+ CGM.getTargetCodeGenInfo ().setOCLKernelStubCallingConvention (FT);
517+ FTy = FT->getCanonicalTypeUnqualified ();
518+ }
519+
512520 // When declaring a function without a prototype, always use a
513521 // non-variadic type.
514522 if (CanQual<FunctionNoProtoType> noProto = FTy.getAs <FunctionNoProtoType>()) {
@@ -581,13 +589,11 @@ CodeGenTypes::arrangeUnprototypedObjCMessageSend(QualType returnType,
581589const CGFunctionInfo &
582590CodeGenTypes::arrangeGlobalDeclaration (GlobalDecl GD) {
583591 // FIXME: Do we need to handle ObjCMethodDecl?
584- const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl ());
585-
586592 if (isa<CXXConstructorDecl>(GD.getDecl ()) ||
587593 isa<CXXDestructorDecl>(GD.getDecl ()))
588594 return arrangeCXXStructorDeclaration (GD);
589595
590- return arrangeFunctionDeclaration (FD );
596+ return arrangeFunctionDeclaration (GD );
591597}
592598
593599// / Arrange a thunk that takes 'this' as the first parameter followed by
@@ -2391,7 +2397,6 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
23912397 // Collect function IR attributes from the callee prototype if we have one.
23922398 AddAttributesFromFunctionProtoType (getContext (), FuncAttrs,
23932399 CalleeInfo.getCalleeFunctionProtoType ());
2394-
23952400 const Decl *TargetDecl = CalleeInfo.getCalleeDecl ().getDecl ();
23962401
23972402 // Attach assumption attributes to the declaration. If this is a call
@@ -2498,7 +2503,11 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
24982503 NumElemsParam);
24992504 }
25002505
2501- if (TargetDecl->hasAttr <OpenCLKernelAttr>()) {
2506+ if (TargetDecl->hasAttr <OpenCLKernelAttr>() &&
2507+ CallingConv != CallingConv::CC_C &&
2508+ CallingConv != CallingConv::CC_SpirFunction) {
2509+ // Check CallingConv to avoid adding uniform-work-group-size attribute to
2510+ // OpenCL Kernel Stub
25022511 if (getLangOpts ().OpenCLVersion <= 120 ) {
25032512 // OpenCL v1.2 Work groups are always uniform
25042513 FuncAttrs.addAttribute (" uniform-work-group-size" , " true" );
0 commit comments