Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

typedef types not allowed in vector declaration context #38239

Closed Quuxplusone closed 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR39266
Status RESOLVED WONTFIX
Importance P enhancement
Reported by Jinsong Ji (jji@us.ibm.com)
Reported on 2018-10-12 10:07:00 -0700
Last modified on 2018-10-18 08:34:32 -0700
Version trunk
Hardware PC All
CC hfinkel@anl.gov, llvm-bugs@lists.llvm.org, paulsson@linux.vnet.ibm.com, richard-llvm@metafoo.co.uk, uweigand@de.ibm.com, wschmidt@linux.vnet.ibm.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
$ cat vector_typedef.c
typedef unsigned int ui;
int main(){
__vector unsigned int res;
vector unsigned int res2;
__vector ui bad;
return 0;
}
$ clang -c vector_typedef.c
vector_typedef.c:5:10: warning: type specifier missing, defaults to 'int' [-
Wimplicit-int]
__vector ui bad;
~~~~~~~~ ^
vector_typedef.c:5:12: error: expected ';' at end of declaration
__vector ui bad;
           ^
           ;
1 warning and 1 error generated.
$ /opt/at11.0/bin/g++ -c vector_typedef.c
Quuxplusone commented 6 years ago

In case anyone else is confused, this code is using the SystemZ vector language extension.

Quuxplusone commented 6 years ago

We would like to enable it on Power as well. Thanks.

Quuxplusone commented 6 years ago
The AltiVec specification is quite clear that this code is ill-formed. Section
2.2 of the specification says:

"The syntax does not allow the use of a typedef name as a type specifier. For
example, the following is not allowed:

typedef signed short int16;
vector int16 data;"

(In reply to Eli Friedman from comment #1)
> In case anyone else is confused, this code is using the SystemZ vector
> language extension.

Is there an actual specification for the SystemZ vector extensions somewhere?
All I can find is a vague statement that they are "based on AltiVec".
Quuxplusone commented 6 years ago
(In reply to Eli Friedman from comment #1)

> In case anyone else is confused, this code is using the SystemZ
> vector language extension.

Actually, I believe this really is the Power AltiVec extension ("/opt/at11.0"
refers to the Power Advance Toolchain, which isn't available on Z).

(In reply to Richard Smith from comment #3)

> The AltiVec specification is quite clear that this code is
> ill-formed. Section 2.2 of the specification says:
>
> "The syntax does not allow the use of a typedef name as a
> type specifier. For example, the following is not allowed:
>
> typedef signed short int16;
> vector int16 data;"

Interestingly enough, *that* actually fails with GCC too.  It seems GCC accepts
a typedef with "__vector", but *not* "vector".  This is quite weird, and really
looks more like a GCC bug to me ...

> Is there an actual specification for the SystemZ vector extensions
> somewhere? All I can find is a vague statement that they are "based on
> AltiVec".

Not as a separate document, unfortunately.  The extension as implemented in GCC
and LLVM is supposed to be (mostly) compatible with the extension implemented
in the IBM XL compiler. That extension is documented in the XL programming
guide:

https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.cbcpx01/vectorsupport.htm

Overall, it seems the behavior is (mostly) the same on Power and Z: the
language extension specification does *not* support "vector typedef", and both
GCC and clang reject typedef with the "vector" keyword.  GCC does accept
typedefs with the "__vector" keyword just like on Power -- probably the same
bug.

However, for some reason, clang on Z does not appear to accept __vector at all.
Not sure what's going on there, I'll have a look.
Quuxplusone commented 6 years ago
(In reply to Ulrich Weigand from comment #4)

> However, for some reason, clang on Z does not appear to accept __vector at
> all.  Not sure what's going on there, I'll have a look.

Oops, that was my fault, it seems.  Now fixed in r344611.
Quuxplusone commented 6 years ago

Thanks all! So close this since AltiVec specification says this is ill-formed.