This is an archive of the discontinued LLVM Phabricator instance.

BuildVectorType with a dependent (array) type is crashing the compiler - Fix for PR-47542
ClosedPublic

Authored by zahiraam on Sep 23 2020, 6:35 AM.

Diff Detail

Event Timeline

zahiraam requested review of this revision.Sep 23 2020, 6:35 AM
zahiraam created this revision.
rnk added inline comments.Sep 28 2020, 10:01 AM
clang/lib/Sema/SemaType.cpp
2523

It looks like clang and gcc treat this attribute on array types differently. Consider the non-dependent case:
https://gcc.godbolt.org/z/n6Prfd

typedef int myvect[4] __attribute__((vector_size(16)));

GCC treats this as an array of four 16 byte vectors. Clang tries to apply the attribute to the array type and rejects it here, rather than applying it to the inner type.

I think the change is correct, but I'd suggest simplifying the condition: we can reject the vector_size attribute on all array types, whether they are dependent or not. You should be able to remove the CurType->isDependentType() && clause. Can you make sure we have a test for the non-dependent array type case? You can use the typedef I have above.

zahiraam updated this revision to Diff 294779.Sep 28 2020, 12:33 PM
zahiraam marked an inline comment as done.
rnk accepted this revision.Sep 28 2020, 12:35 PM

Thanks!

This revision is now accepted and ready to land.Sep 28 2020, 12:35 PM
In D88150#2298923, @rnk wrote:

Thanks!

Thank you! Would you mind merge it in please? Thanks.

Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2020, 5:10 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript