Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hipExtLaunchKernelGGL. Remove zombies #183

Open
wants to merge 1 commit into
base: clang_tot_upgrade
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions lib/CodeGen/CGRecordLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,19 +611,6 @@ void CGRecordLowering::clipTailPadding() {
}
}

static bool isPassedToHIPGlobalFn(const CXXRecordDecl *MaybeKernarg)
{
if (!MaybeKernarg) return false;
if (!MaybeKernarg->hasAttr<AnnotateAttr>()) return false;

// N.B.: this is set in Sema::GatherArgumentsForCall, via
// MarkByValueRecordsPassedToHIPGlobalFN.
static constexpr const char HIPKernargRecord[]{"__HIP_KERNARG_RECORD__"};

return MaybeKernarg->getAttr<AnnotateAttr>()->getAnnotation()
.find(HIPKernargRecord) != StringRef::npos;
}

void CGRecordLowering::determinePacked(bool NVBaseType) {
if (Packed)
return;
Expand Down
12 changes: 9 additions & 3 deletions lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<UnresolvedLookupExpr>(F)) {
Expand All @@ -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<UnresolvedLookupExpr>(F),
Expand Down
31 changes: 0 additions & 31 deletions lib/Sema/SemaTemplateInstantiateDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PackedAttr>()) 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
Expand Down Expand Up @@ -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;
}

Expand Down