Skip to content

[AMDGPU] OCL12 Adapter: avoid processing of special C++ functions #50

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

Open
wants to merge 1 commit into
base: amd-common
Choose a base branch
from
Open
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
27 changes: 16 additions & 11 deletions lib/Target/AMDGPU/AMDGPUOCL12Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static bool locateFuncName(StringRef FuncName, size_t &FuncNameStart,
// are "_Z" in the mangling scheme.
size_t NumStartPos = 2;
FuncNameStart = FuncName.find_first_not_of("0123456789", NumStartPos);
assert(FuncNameStart != NumStartPos);
// Extract the integer, which is equal to the number of chars
// in the function name.
StringRef SizeInChar = FuncName.slice(NumStartPos, FuncNameStart);
Expand Down Expand Up @@ -208,18 +209,22 @@ static bool findAndDefineBuiltinCalls(Module &M) {

// Search only for used, undefined OpenCL builtin functions,
// which has non-default addr space pointer arguments.
if (!F.empty() || F.use_empty() || !F.getName().startswith("_Z") ||
!hasNonDefaultAddrSpaceArg(&F))
if (!F.empty() || F.use_empty() || !hasNonDefaultAddrSpaceArg(&F))
continue;
if (F.getName().find("async_work_group", 0) == StringRef::npos &&
F.getName().find("prefetch", 0) == StringRef::npos) {
isModified = true;
Function *NewFunc = getNewOCL20BuiltinFuncDecl(&F);
// Get the new Function declaration.
DEBUG(dbgs() << "\n Modifying Func " << F.getName() << " to call "
<< NewFunc->getName() << " Function");
createOCL20BuiltinFuncDefn(&F, NewFunc);
}

auto const Name = F.getName();
if (!Name.startswith("_Z") ||
Name.find_first_of("123456789", 2) != 2 ||
Name.find("async_work_group", 3) != StringRef::npos ||
Name.find("prefetch", 3) != StringRef::npos)
continue;

Function *NewFunc = getNewOCL20BuiltinFuncDecl(&F);
// Get the new Function declaration.
DEBUG(dbgs() << "\n Modifying Func " << Name << " to call "
<< NewFunc->getName() << " Function");
createOCL20BuiltinFuncDefn(&F, NewFunc);
isModified = true;
}
return isModified;
}
Expand Down