[HIPIFY][#199][Partial fix] Fix for cudaLaunchKernel transformation
[Synopsis]
If any of kernel arguments is a MACRO its location calculation is wrong (location of its definition is actually calculated).
Thus garbage code is being produced on the place of such a MACRO starting from the end of its actual definition.
[Solution]
Add isMacroBodyExpansion and isMacroArgExpansion checks on kernel arguments.
[ROCm/hip commit: 7ee8e2d51b]
This commit is contained in:
@@ -3314,7 +3314,17 @@ private:
|
||||
for (unsigned argno = 0; argno < launchKernel->getNumArgs(); argno++) {
|
||||
const Expr *arg = launchKernel->getArg(argno);
|
||||
SourceLocation sl(arg->getLocStart());
|
||||
if (SM->isMacroBodyExpansion(sl)) {
|
||||
sl = SM->getExpansionLoc(sl);
|
||||
} else if (SM->isMacroArgExpansion(sl)) {
|
||||
sl = SM->getImmediateSpellingLoc(sl);
|
||||
}
|
||||
SourceLocation el(arg->getLocEnd());
|
||||
if (SM->isMacroBodyExpansion(el)) {
|
||||
el = SM->getExpansionLoc(el);
|
||||
} else if (SM->isMacroArgExpansion(el)) {
|
||||
el = SM->getImmediateSpellingLoc(el);
|
||||
}
|
||||
SourceLocation stop = Lexer::getLocForEndOfToken(el, 0, *SM, DefaultLangOptions);
|
||||
std::string outs(SM->getCharacterData(sl), SM->getCharacterData(stop) - SM->getCharacterData(sl));
|
||||
DEBUG(dbgs() << outs << "\n");
|
||||
|
||||
Reference in New Issue
Block a user