Add support for vector mode attributes like "attribute((mode(V4SF)))". Also add warning about deprecated vector modes like GCC does.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I am a little bit confused -- this patch adds a deprecation warning for vector sizes and claims that the attribute is ignored (by placing it in the IgnoredAttributes group), but then provides the initial implementation for this functionality and makes use of the attribute. If it's deprecated, why implement the behavior? Better to say "we recognize this attribute and won't explode on it, but do not implement the functionality since it is deprecated."
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
2765 ↗ | (On Diff #40384) | How about: "'mode' attribute is not supported for vector types; use the 'vector_size' attribute instead" |
Thank you for prompt response!
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
2765 ↗ | (On Diff #40384) | Both GCC and ICC support vector types in mode attribute with similar warning so for compatibility reasons it is better to implement it. Taking into account that detection of vector types is more than half of supporting them. I do agree that warning group is confusing. I was not able to find more suitable warning group so would you recommend to create new one for this warning? |
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
2765 ↗ | (On Diff #40384) | Are there headers from major library vendors that rely on supporting this feature? If not, then I would say it's probably better to simply not implement the diagnostic and fail to support such constructs at all. If it is used by major vendors and would prevent otherwise functional code from working, then this approach is reasonable. In that case, I would add a new diagnostic group (DeprecatedAttributes and add it to the Deprecated group). |
Added new warning group as suggested.
I see thousands of vector types in headers on GitHub https://github.com/search?p=1&q=%22__attribute__+mode+v4sf%22+extension%3Ah&ref=searchresults&type=Code&utf8=%E2%9C%93
liboil from freedesktop.org uses vector types in headers.
The vast majority of those headers all appear to be GCC's vector-defs.h, so I'm still not convinced this is actually something we need to solve. However, I also don't see the harm.
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
2828 ↗ | (On Diff #40489) | Should be reworded slightly to be consistent with other attribute diagnostics: "specifying vector types with the 'mode' attribute is deprecated; use the 'vector_size' attribute instead" |
lib/Sema/SemaDeclAttr.cpp | ||
3239 ↗ | (On Diff #40489) | parseModeAttrArg() please. |
3315 ↗ | (On Diff #40489) | Can you have a vector of vectors with mode? I'm wondering why this isn't part of parseModeAttr(), since this is parsing part of the mode attribute. |
3318 ↗ | (On Diff #40489) | This will cause a buffer overrun on pathological code; should also constrain based on the size of Str. |