This is an archive of the discontinued LLVM Phabricator instance.

[2/11][Clang][RISCV] Expand all variants of RVV intrinsic tuple types
ClosedPublic

Authored by eopXD on Jun 3 2023, 10:50 AM.

Details

Summary

This is the 2nd patch of the patch-set. For the cover letter, please
checkout D152069.

Depends on D152069.

This patch also removes redundant checks related to tuples and dedicate
the check to happen in RVVType::verifyType.

Diff Detail

Event Timeline

eopXD created this revision.Jun 3 2023, 10:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2023, 10:50 AM
eopXD requested review of this revision.Jun 3 2023, 10:50 AM
eopXD retitled this revision from [2/N][Clang][RISCV] Expand all variants of RVV intrinsic tuple types to [2/11][Clang][RISCV] Expand all variants of RVV intrinsic tuple types.Jun 3 2023, 10:55 AM
eopXD edited the summary of this revision. (Show Details)
eopXD edited the summary of this revision. (Show Details)
eopXD edited the summary of this revision. (Show Details)Jun 3 2023, 11:05 AM
eopXD edited the summary of this revision. (Show Details)Jun 3 2023, 11:07 AM
eopXD edited the summary of this revision. (Show Details)Jun 3 2023, 11:09 AM
eopXD updated this revision to Diff 528135.Jun 3 2023, 11:12 AM

Bump CI.

craig.topper added inline comments.Jun 5 2023, 4:44 PM
clang/include/clang/Basic/RISCVVTypes.def
224

Blank line before the start of each section

clang/utils/TableGen/RISCVVEmitter.cpp
161

case should start at the same column as switch

163

Inconsistent formatting between case 2-3 and 4-8.

eopXD updated this revision to Diff 528717.Jun 6 2023, 12:07 AM
eopXD marked 3 inline comments as done.

Address comments from Craig.
Also simplify code to get VectorTypeModifer for tuples.

eopXD updated this revision to Diff 529152.Jun 6 2023, 9:53 PM

Bump CI based on change in parent revision.

kito-cheng added inline comments.Jun 8 2023, 6:03 AM
clang/lib/Support/RISCVVIntrinsicUtils.cpp
819

Keep as assert?

eopXD added inline comments.Jun 8 2023, 8:32 AM
clang/lib/Support/RISCVVIntrinsicUtils.cpp
819

computeType already has an assertion guarding it, which is why the condition is removed here.

This revision is now accepted and ready to land.Jun 8 2023, 11:27 AM
craig.topper added inline comments.Jun 8 2023, 11:29 AM
clang/lib/Support/RISCVVIntrinsicUtils.cpp
737

Could maybe merge these into a single case body and use math to compute NF?

eopXD updated this revision to Diff 529686.Jun 8 2023, 11:33 AM
eopXD marked an inline comment as done.

Address comment from Craig.

eopXD updated this revision to Diff 531199.Jun 13 2023, 11:45 PM

Rebase to latest main.

This revision was landed with ongoing or failed builds.Jun 13 2023, 11:45 PM
This revision was automatically updated to reflect the committed changes.

FYI after this change:

Building CXX object tools/lldb/sou...luginTypeSystemClang.dir/TypeSystemClang.cpp.o
/home/david.spickett/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4843:13: warning: 225 enumeration values not handled in switch: 'RvvInt8mf8x2', 'RvvInt8mf8x3', 'RvvInt8mf8x4'... [-Wswitch]
    switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lldb doesn't do anything with RVV yet, so you can likely just add all the names to the existing block of RVV stuff that just breaks at the end.

FYI after this change:

Building CXX object tools/lldb/sou...luginTypeSystemClang.dir/TypeSystemClang.cpp.o
/home/david.spickett/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4843:13: warning: 225 enumeration values not handled in switch: 'RvvInt8mf8x2', 'RvvInt8mf8x3', 'RvvInt8mf8x4'... [-Wswitch]
    switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lldb doesn't do anything with RVV yet, so you can likely just add all the names to the existing block of RVV stuff that just breaks at the end.

This might be the cause to a crash I'm observing and that bisect pointed to.

Reproducer:

$ touch t.c # empty file
$ clang -cc1 -triple riscv64 -w -emit-pch -o test.pch t.c
$ clang -cc1 -triple riscv64 -w -x c -include-pch test.pch -ast-dump-all /dev/null
eopXD added a comment.Jun 15 2023, 9:56 AM

FYI after this change:

Building CXX object tools/lldb/sou...luginTypeSystemClang.dir/TypeSystemClang.cpp.o
/home/david.spickett/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4843:13: warning: 225 enumeration values not handled in switch: 'RvvInt8mf8x2', 'RvvInt8mf8x3', 'RvvInt8mf8x4'... [-Wswitch]
    switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lldb doesn't do anything with RVV yet, so you can likely just add all the names to the existing block of RVV stuff that just breaks at the end.

This might be the cause to a crash I'm observing and that bisect pointed to.

Reproducer:

$ touch t.c # empty file
$ clang -cc1 -triple riscv64 -w -emit-pch -o test.pch t.c
$ clang -cc1 -triple riscv64 -w -x c -include-pch test.pch -ast-dump-all /dev/null

Warning (and possibly the error you got) should be fixed now through https://reviews.llvm.org/D152922.

FYI after this change:

Building CXX object tools/lldb/sou...luginTypeSystemClang.dir/TypeSystemClang.cpp.o
/home/david.spickett/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4843:13: warning: 225 enumeration values not handled in switch: 'RvvInt8mf8x2', 'RvvInt8mf8x3', 'RvvInt8mf8x4'... [-Wswitch]
    switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lldb doesn't do anything with RVV yet, so you can likely just add all the names to the existing block of RVV stuff that just breaks at the end.

This might be the cause to a crash I'm observing and that bisect pointed to.

Reproducer:

$ touch t.c # empty file
$ clang -cc1 -triple riscv64 -w -emit-pch -o test.pch t.c
$ clang -cc1 -triple riscv64 -w -x c -include-pch test.pch -ast-dump-all /dev/null

Warning (and possibly the error you got) should be fixed now through https://reviews.llvm.org/D152922.

Sorry @eopXD I confused everyone by linking the clang issue with that of lldb and they are unrelated. Apologies.

Can you check if clang crashes for you?

FYI after this change:

Building CXX object tools/lldb/sou...luginTypeSystemClang.dir/TypeSystemClang.cpp.o
/home/david.spickett/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4843:13: warning: 225 enumeration values not handled in switch: 'RvvInt8mf8x2', 'RvvInt8mf8x3', 'RvvInt8mf8x4'... [-Wswitch]
    switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lldb doesn't do anything with RVV yet, so you can likely just add all the names to the existing block of RVV stuff that just breaks at the end.

This might be the cause to a crash I'm observing and that bisect pointed to.

Reproducer:

$ touch t.c # empty file
$ clang -cc1 -triple riscv64 -w -emit-pch -o test.pch t.c
$ clang -cc1 -triple riscv64 -w -x c -include-pch test.pch -ast-dump-all /dev/null

Warning (and possibly the error you got) should be fixed now through https://reviews.llvm.org/D152922.

Sorry @eopXD I confused everyone by linking the clang issue with that of lldb and they are unrelated. Apologies.

Can you check if clang crashes for you?

I am seeing messages related to builtin type, but they do not seem related to RVV builtin types.

$ touch t.c
$ clang -cc1 -triple riscv64 -w -emit-pch -o test.pch t.c
$ clang -cc1 -triple riscv64 -w -x c -include-pch test.pch -ast-dump-all /dev/null
TranslationUnitDecl 0x60f3f88 <<invalid sloc>> <invalid sloc> <undeserialized declarations>
|-TypedefDecl 0x60f4b78 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x60f4520 '__int128'
|-TypedefDecl 0x60f4be8 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x60f4540 'unsigned __int128'
|-TypedefDecl 0x60f4ae8 <<invalid sloc>> <invalid sloc> implicit __NSConstantString 'struct __NSConstantString_tag'
| `-RecordType 0x60f48c0 'struct __NSConstantString_tag' imported
|   `-Record 0x60f4828 '__NSConstantString_tag'
`-TypedefDecl 0x60f4c58 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'void *'
  `-PointerType 0x60f47a0 'void *'
    `-BuiltinType 0x60f3fe0 'void'
rogfer01 added a comment.EditedJun 15 2023, 10:39 AM

Can you check if clang crashes for you?

I am seeing messages related to builtin type, but they do not seem related to RVV builtin types.

$ touch t.c
$ clang -cc1 -triple riscv64 -w -emit-pch -o test.pch t.c
$ clang -cc1 -triple riscv64 -w -x c -include-pch test.pch -ast-dump-all /dev/null
TranslationUnitDecl 0x60f3f88 <<invalid sloc>> <invalid sloc> <undeserialized declarations>
|-TypedefDecl 0x60f4b78 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x60f4520 '__int128'
|-TypedefDecl 0x60f4be8 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x60f4540 'unsigned __int128'
|-TypedefDecl 0x60f4ae8 <<invalid sloc>> <invalid sloc> implicit __NSConstantString 'struct __NSConstantString_tag'
| `-RecordType 0x60f48c0 'struct __NSConstantString_tag' imported
|   `-Record 0x60f4828 '__NSConstantString_tag'
`-TypedefDecl 0x60f4c58 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'void *'
  `-PointerType 0x60f47a0 'void *'
    `-BuiltinType 0x60f3fe0 'void'

Thanks @eopXD.

What I've seen is that the test stops crashing for me if I disable all the types starting from line 218 in file clang/include/clang/Basic/RISCVVTypes.def.

When it doesn't crash, in my case all the registered RVV types are shown in the output

TranslationUnitDecl 0x14647eb8 <<invalid sloc>> <invalid sloc> <undeserialized declarations>
|-TypedefDecl 0x14649e00 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x14648480 '__int128'
|-TypedefDecl 0x14649e70 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x146484a0 'unsigned __int128'
|-TypedefDecl 0x14649d68 <<invalid sloc>> <invalid sloc> implicit __NSConstantString 'struct __NSConstantString_tag'
| `-RecordType 0x14649b40 'struct __NSConstantString_tag' imported
|   `-Record 0x14649aa0 '__NSConstantString_tag'
|-TypedefDecl 0x14649ed0 <<invalid sloc>> <invalid sloc> imported implicit __rvv_int8mf8_t '__rvv_int8mf8_t'
| `-BuiltinType 0x14648640 '__rvv_int8mf8_t'
|-TypedefDecl 0x14649f58 <<invalid sloc>> <invalid sloc> imported implicit __rvv_int8mf4_t '__rvv_int8mf4_t'
| `-BuiltinType 0x14648660 '__rvv_int8mf4_t'
|-TypedefDecl 0x14649fe0 <<invalid sloc>> <invalid sloc> imported implicit __rvv_int8mf2_t '__rvv_int8mf2_t'
| `-BuiltinType 0x14648680 '__rvv_int8mf2_t'
|-TypedefDecl 0x1464a068 <<invalid sloc>> <invalid sloc> imported implicit __rvv_int8m1_t '__rvv_int8m1_t'
| `-BuiltinType 0x146486a0 '__rvv_int8m1_t'
|-TypedefDecl 0x1464a0f0 <<invalid sloc>> <invalid sloc> imported implicit __rvv_int8m2_t '__rvv_int8m2_t'
| `-BuiltinType 0x146486c0 '__rvv_int8m2_t'
|-TypedefDecl 0x1464a178 <<invalid sloc>> <invalid sloc> imported implicit __rvv_int8m4_t '__rvv_int8m4_t'
…

Curious that you don't observe this. I'll keep investigating.

It looks like we need to increase NUM_PREDEF_TYPE_IDS. Let's continue the discussion on D153111