From f0426c32d6d9a22cb2d56a149e7ef607ddc372d4 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Sat, 12 Oct 2019 14:57:50 +0300 Subject: [PATCH] Add support for hipExtLaunchKernelGGL. Remove zombies --- lib/CodeGen/CGRecordLayoutBuilder.cpp | 13 ---------- lib/Sema/SemaOverload.cpp | 12 ++++++--- lib/Sema/SemaTemplateInstantiateDecl.cpp | 31 ------------------------ 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index 73e4396edc5..4de64a32f2a 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -611,19 +611,6 @@ void CGRecordLowering::clipTailPadding() { } } -static bool isPassedToHIPGlobalFn(const CXXRecordDecl *MaybeKernarg) -{ - if (!MaybeKernarg) return false; - if (!MaybeKernarg->hasAttr()) return false; - - // N.B.: this is set in Sema::GatherArgumentsForCall, via - // MarkByValueRecordsPassedToHIPGlobalFN. - static constexpr const char HIPKernargRecord[]{"__HIP_KERNARG_RECORD__"}; - - return MaybeKernarg->getAttr()->getAnnotation() - .find(HIPKernargRecord) != StringRef::npos; -} - void CGRecordLowering::determinePacked(bool NVBaseType) { if (Packed) return; diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 351cd8b085d..525dfb09bde 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -12526,10 +12526,16 @@ static void maybeCastArgsForHIPGlobalFunction(Sema &S, UnresolvedLookupExpr *ULE, MultiExprArg Args) { static constexpr const char HIPLaunch[]{"hipLaunchKernelGGL"}; + static constexpr const char HIPExtLaunch[]{"hipExtLaunchKernelGGL"}; - if (ULE->getName().getAsString().find(HIPLaunch) == std::string::npos) { + const bool IsHIPLaunch{ + ULE->getName().getAsString().find(HIPLaunch) != std::string::npos}; + const bool IsHIPExtLaunch{ + !IsHIPLaunch && + ULE->getName().getAsString().find(HIPExtLaunch) != std::string::npos}; + + if (!IsHIPLaunch && !IsHIPExtLaunch) return; - } auto F = Args.front(); while (!isa(F)) { @@ -12539,7 +12545,7 @@ static void maybeCastArgsForHIPGlobalFunction(Sema &S, F = PE->getSubExpr(); } - static constexpr unsigned int IgnoreCnt{5u}; // Skip launch configuration. + const unsigned int IgnoreCnt{IsHIPLaunch ? 5u : 8u}; // Skip launch configuration. FunctionDecl *FD = getBestCandidateForHIP(S, cast(F), diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index dbcb605df60..cc7903ed7f7 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1754,31 +1754,6 @@ static QualType adjustFunctionTypeForInstantiation(ASTContext &Context, NewFunc->getParamTypes(), NewEPI); } -static void MarkByValueRecordsPassedToHIPGlobalFN(FunctionDecl *FDecl) -{ // TODO: this is a temporary kludge; a preferable solution shall be provided - // in the future, which shall eschew FE involvement. - static constexpr const char HIPLaunch[]{"hipLaunchKernelGGL"}; - - if (!FDecl) return; - if (FDecl->getDeclName().isIdentifier() && - FDecl->getNameAsString().find(HIPLaunch) == std::string::npos) return; - - for (auto &&Parameter : FDecl->parameters()) { - if (Parameter->getOriginalType()->isPointerType()) continue; - if (Parameter->getOriginalType()->isReferenceType()) continue; - if (!Parameter->getOriginalType()->isRecordType()) continue; - - if (auto RD = Parameter->getOriginalType()->getAsCXXRecordDecl()) { - if (RD->hasAttr()) continue; // Spurious for lambdas. - if (!RD->isLambda()) continue; - - static constexpr const char HIPKernargRecord[]{"__HIP_KERNARG_RECORD__"}; - RD->addAttr( - AnnotateAttr::CreateImplicit(RD->getASTContext(), HIPKernargRecord)); - } - } -} - /// Normal class members are of more specific types and therefore /// don't make it here. This function serves three purposes: /// 1) instantiating function templates @@ -2081,12 +2056,6 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D, assert(!D->isDefaulted() && "only methods should be defaulted"); - - if (SemaRef.getLangOpts().CPlusPlusAMP) { - // TODO: kludge warning, to be removed. - MarkByValueRecordsPassedToHIPGlobalFN(Function); - } - return Function; }