[PATCH] D71241: [OpenMP][WIP] Use overload centric declare variants
Alexey Bataev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 16 13:21:42 PST 2019
ABataev added a comment.
Most probably, we can use this solution without adding a new expression. `DeclRefExpr` class can contain 2 decls: FoundDecl and the Decl being used. You can use FoundDecl to point to the original function and used decl to point to the function being called in this context. But at first, we need to be sure that we can handle all corner cases correctly.
For example, can it handle such cases as:
t1.c:
int hst();
#pragma omp declare variant(hst) match(device={kind(host)})
int base();
t2.c:
int main() {
return base();
}
This is the correct C code, I assume. At least, clang compiles it.
Another problem:
t1.c:
int hst();
#pragma omp declare varint(hst) match(device={kind(host)})
int base();
t2.c:
int base() { return 0; }
int main() {
return base();
}
According to the standard, this is valid code and `hst` function must be called (though it is not correct since in C/C++ each definition is a declaration and all restriction applied to the declaration must be applied to the definition too).
Another one possible problem might be with the templates:
template <typename T> T base() { return T(); }
int hst() { return 1; }
int main() {
return base<int>();
}
#pragma omp declare variant(hst) match(device={kind(gpu)})
template<typename T>
T base();
int foo() {
return base<int>();
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71241/new/
https://reviews.llvm.org/D71241
More information about the cfe-commits
mailing list