Allow (implicit) address space casting between LLVM-equivalent
target address spaces.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
we need a codegen test for the case
clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
6550 | we still need to keep this condition so it should be: if ((ArgAS != LangAS::Default && getASTContext().getTargetAddressSpace(ArgAS) != getASTContext().getTargetAddressSpace(ParamAS)) || ParamAS == LangAS::Default) |
clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
6548–6553 | I'd rephrase it in terms of add ASC if target AS is different. Prevent assumes that we've already decided to add an ASC, while it is not the case. All we know is that we've got a pointer argument and we are figuring out whether ASC is needed. | |
clang/test/SemaCUDA/builtins-unsafe-atomics-gfx90a.cu | ||
4 | You do not want to produce any output. I think -fsyntax-only -verify along with // expected-no-diagnostics should do the trick. | |
9 | Not needed w/o FileCheck. |
LGTM in general, modulo a readability suggestion.
clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
6548–6553 | Hmm. I guess that does not quite match what we do here. So the test case currently does fail, because we end up w/o implicit ASC and end up trying to pass wrong types of pointers. https://godbolt.org/z/MaWMbGb5z Now we actually want to allow implicit ASC for the pointer types that are in the *same* target AS, so my comment suggestion was actually wrong. This confusion also suggests that the condition is hard to understand. Perhaps we can rewrite it. E.g. bool NeedImplicitASC = ParamAS != LangAS::Default && // Pointers params in generic AS don't need special handling. ( ArgAs == LangAS::Default || // We do allow implicit conversion from generic AS // or from specific AS which has target AS matching that of Param. getASTContext().getTargetAddressSpace(ArgAS) == getASTContext().getTargetAddressSpace(ParamAS)); if (!NeedImplicitASC) continue; |
It could've been done with a follow-up clean-up commit. revert/reland works, too. Thank you for following up on the comment, either way.
we still need to keep this condition so it should be: