[HIPIFY] [Fix] Crash on thrust example fallback_allocator.cu.
https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/65
[Bug]
Access violation in cudaStructVar matcher.
StringRef name = structVar->getType()
->getAsStructureType()
->getDecl() // <--- Access Violation
->getNameAsString();
[Solution]
Add isStructureType() check before getting type as Struct.
[ToDo]
Find case-studies for that StructVar matcher with types other than Struct.
[ROCm/hip commit: 950434f4af]
Этот коммит содержится в:
@@ -2282,25 +2282,27 @@ private:
|
||||
|
||||
bool cudaStructVar(const MatchFinder::MatchResult &Result) {
|
||||
if (const VarDecl *structVar = Result.Nodes.getNodeAs<VarDecl>("cudaStructVar")) {
|
||||
StringRef name = structVar->getType()
|
||||
->getAsStructureType()
|
||||
->getDecl()
|
||||
->getNameAsString();
|
||||
TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc();
|
||||
SourceLocation sl = TL.getUnqualifiedLoc().getLocStart();
|
||||
SourceManager *SM = Result.SourceManager;
|
||||
const auto found = N.cuda2hipRename.find(name);
|
||||
if (found != N.cuda2hipRename.end()) {
|
||||
updateCounters(found->second, name.str());
|
||||
if (!found->second.unsupported) {
|
||||
StringRef repName = found->second.hipName;
|
||||
Replacement Rep(*SM, sl, name.size(), repName);
|
||||
FullSourceLoc fullSL(sl, *SM);
|
||||
insertReplacement(Rep, fullSL);
|
||||
QualType QT = structVar->getType();
|
||||
// ToDo: find case-studies with types other than Struct.
|
||||
if (QT->isStructureType()) {
|
||||
StringRef name = QT.getTypePtr()->getAsStructureType()->getDecl()->getNameAsString();
|
||||
TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc();
|
||||
SourceLocation sl = TL.getUnqualifiedLoc().getLocStart();
|
||||
SourceManager *SM = Result.SourceManager;
|
||||
const auto found = N.cuda2hipRename.find(name);
|
||||
if (found != N.cuda2hipRename.end()) {
|
||||
updateCounters(found->second, name.str());
|
||||
if (!found->second.unsupported) {
|
||||
StringRef repName = found->second.hipName;
|
||||
Replacement Rep(*SM, sl, name.size(), repName);
|
||||
FullSourceLoc fullSL(sl, *SM);
|
||||
insertReplacement(Rep, fullSL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var].";
|
||||
printHipifyMessage(*SM, sl, msg);
|
||||
}
|
||||
} else {
|
||||
std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var].";
|
||||
printHipifyMessage(*SM, sl, msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user