SWDEV-341360 - Handle named expressions with space in hipRTC
Change-Id: I1c26855d8a94e0a4d818664ca71094c6992221c9
This commit is contained in:
@@ -288,25 +288,21 @@ bool RTCCompileProgram::compile(const std::vector<std::string>& options, bool fg
|
||||
}
|
||||
|
||||
std::vector<std::string> mangledNames;
|
||||
if (!fillDemangledNames(executable_, mangledNames)) {
|
||||
LogError("Error in hiprtc: unable to fill demangled names");
|
||||
if (!fillMangledNames(executable_, mangledNames)) {
|
||||
LogError("Error in hiprtc: unable to fill mangled names");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getMangledNames(mangledNames, stripped_names_, demangled_names_)) {
|
||||
LogError("Error in hiprtc: unable to get mangled names");
|
||||
if (!getDemangledNames(mangledNames, demangled_names_)) {
|
||||
LogError("Error in hiprtc: unable to get demangled names");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTCCompileProgram::trackMangledName(std::string& name) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
void RTCCompileProgram::stripNamedExpression(std::string& strippedName) {
|
||||
|
||||
if (name.size() == 0) return false;
|
||||
|
||||
std::string strippedName = name;
|
||||
if (strippedName.back() == ')') {
|
||||
strippedName.pop_back();
|
||||
strippedName.erase(0, strippedName.find('('));
|
||||
@@ -314,16 +310,24 @@ bool RTCCompileProgram::trackMangledName(std::string& name) {
|
||||
if (strippedName.front() == '&') {
|
||||
strippedName.erase(0, 1);
|
||||
}
|
||||
|
||||
std::string strippedNameNoSpace = strippedName;
|
||||
strippedNameNoSpace.erase(std::remove_if(strippedNameNoSpace.begin(),
|
||||
strippedNameNoSpace.end(),
|
||||
// Removes the spaces from strippedName if present
|
||||
strippedName.erase(std::remove_if(strippedName.begin(),
|
||||
strippedName.end(),
|
||||
[](unsigned char c) {
|
||||
return std::isspace(c);
|
||||
}), strippedNameNoSpace.end());
|
||||
}), strippedName.end());
|
||||
}
|
||||
|
||||
bool RTCCompileProgram::trackMangledName(std::string& name) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
|
||||
if (name.size() == 0) return false;
|
||||
|
||||
std::string strippedNameNoSpace = name;
|
||||
stripNamedExpression(strippedNameNoSpace);
|
||||
|
||||
stripped_names_.insert(std::pair<std::string, std::string>(name, strippedNameNoSpace));
|
||||
demangled_names_.insert(std::pair<std::string, std::string>(strippedName, ""));
|
||||
demangled_names_.insert(std::pair<std::string, std::string>(strippedNameNoSpace, ""));
|
||||
|
||||
const auto var{"__hiprtc_" + std::to_string(stripped_names_.size())};
|
||||
const auto code{"\nextern \"C\" constexpr auto " + var + " = " + name + ";\n"};
|
||||
@@ -332,23 +336,17 @@ bool RTCCompileProgram::trackMangledName(std::string& name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTCCompileProgram::getDemangledName(const char* name_expression, const char** loweredName) {
|
||||
std::string name = name_expression;
|
||||
if (auto res = stripped_names_.find(name); res != stripped_names_.end()) {
|
||||
if (auto dres = demangled_names_.find(res->second); dres != demangled_names_.end()) {
|
||||
if (dres->second.size() != 0) {
|
||||
*loweredName = dres->second.c_str();
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (auto dres = demangled_names_.find(name); dres != demangled_names_.end()) {
|
||||
bool RTCCompileProgram::getMangledName(const char* name_expression, const char** loweredName) {
|
||||
|
||||
std::string strippedName = name_expression;
|
||||
stripNamedExpression(strippedName);
|
||||
|
||||
if (auto dres = demangled_names_.find(strippedName); dres != demangled_names_.end()) {
|
||||
if (dres->second.size() != 0) {
|
||||
*loweredName = dres->second.c_str();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user