[SYCL] Disable diagnostics for neon attributes for SYCL device compilation - #22877
[SYCL] Disable diagnostics for neon attributes for SYCL device compilation#22877frengels wants to merge 4 commits into
Conversation
Changes in ItaniumMangle.cpp are to make this aux-triple and SYCL aware, which will cause us to go into aarch64 mangling path that correctly handles long long for windows. Checks are added to SemaType to ensure that the selected long or long long is indeed 64-bit, previously this would allow 32-bit long to be a valid polyvector type (which it's not). These are both tested with neon-polyvector-types.cpp. The -verify lines check for error for non 64-bit types, long on windows and int on linux. The -verify=quiet ensures that we use the aarch64 mangling path, the non aarch64 mangling path only accepts long long and not long. Co-authored-by: Lomuller, Victor <vlomuell@qti.qualcomm.com>
|
What was the diagnostic you were seeing before this change? @tahonermann can you take a look at this as well? |
tahonermann
left a comment
There was a problem hiding this comment.
I'm somewhat confused about what the root problem really is. As far as I can tell, NEON polynomial vectors can have base types that are 32-bit (according to ARM documentation) so long as the element count is correct.
The fix for mangling more or less makes sense, though I'm not sure why we would care that mangling of vector types is consistent across host and device compilation.
I noted a few other issues.
| if(S.getLangOpts().SYCLIsDevice) | ||
| Triple = S.Context.getAuxTargetInfo()->getTriple(); |
There was a problem hiding this comment.
getAuxTargetInfo() will return null if an auxiliary target wasn't specified (which is commonly the case in tests).
| llvm::Triple Target = getASTContext().getTargetInfo().getTriple(); | ||
| llvm::Triple::ArchType Arch = | ||
| getASTContext().getTargetInfo().getTriple().getArch(); | ||
| const TargetInfo *TI = getASTContext().getLangOpts().SYCLIsDevice | ||
| ? getASTContext().getAuxTargetInfo() | ||
| : &getASTContext().getTargetInfo(); | ||
| llvm::Triple Target = TI->getTriple(); | ||
| llvm::Triple::ArchType Arch = Target.getArch(); |
There was a problem hiding this comment.
getAuxTargetInfo() will return null if an auxiliary target wasn't specified (which is commonly the case in tests).
| BTy->getKind() == BuiltinType::ULong || | ||
| BTy->getKind() == BuiltinType::ULongLong; | ||
| ((BTy->getKind() == BuiltinType::ULong || | ||
| BTy->getKind() == BuiltinType::ULongLong) && | ||
| S.Context.getTypeSize(BTy) == 64); |
There was a problem hiding this comment.
This doesn't seem right to me. The allowed base types should be independent of the type size. The actual constraint (checked in HandleNeonVectorTypeAttr()) is that the size of the base type multiplied by the number of elements must match the vector size (64-bit or 128-bit).
Is the root problem that unsigned long and unsigned long long have different type sizes for device vs host? If so, we should fix that (even though the SYCL specification doesn't require it).
There was a problem hiding this comment.
Is it important to constrain the specific types used as the base type? Perhaps it would make sense to check for any builtin unsigned integral type with one of the allowed sizes (8, 16, or 64 bit)? Something like:
return BTy->isUnsignedInteger() &&
llvm::any_of(S.Context.getTypeSize(BTy), [](uint64_t n) {
return n == 8 || n == 16 || n == 64
};
There was a problem hiding this comment.
That's what I thought as well, I didn't want to upset the status quo. This would make it simpler and more legible.
|
I don't see Vector data types ^
|
Perhaps that is a documentation mistake. That same doc includes both
I don't see any explicit indication that 32-bit poly types are not supported; most of the docs can be read as implying that they are. |
Sorry, ignore me, I clearly don't know what I'm talking about. When I looked further, other documents do make it clear that |
The original diagnostic was This could be reproduced by any file on windows (possibly also linux) including Now the current situation is that the error we ran into has been fixed in 48b7530, I hadn't seen these when posting this change. I'll remove the SYCL offloading changes from Sema and focus on the |
This is already taken care of by an earlier change to dpc++
This would previously error out as the aux triple wasn't used for checking against neon vector types. Now the aux target is used when sycl is enabled for both sema and mangling.
Changes in ItaniumMangle.cpp are to make this aux-triple and SYCL aware, which will cause us to go into aarch64 mangling path that correctly handles long long for windows.
Checks are added to SemaType to ensure that the selected long or long long is indeed 64-bit, previously this would allow 32-bit long to be a valid polyvector type (which it's not).
These are both tested with neon-polyvector-types.cpp. The -verify lines check for error for non 64-bit types, long on windows and int on linux. The -verify=quiet ensures that we use the aarch64 mangling path, the non aarch64 mangling path only accepts long long and not long.