This is an archive of the discontinued LLVM Phabricator instance.

PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions
ClosedPublic

Authored by maryammo on May 27 2022, 7:05 AM.

Details

Summary

This patch is the last prerequisite to switch the default behaviour to -fno-lax-vector-conversions in the future.
The first path ;D124093; fixed the altivec implicit castings.

Diff Detail

Event Timeline

maryammo created this revision.May 27 2022, 7:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2022, 7:05 AM
maryammo requested review of this revision.May 27 2022, 7:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2022, 7:05 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
maryammo updated this revision to Diff 432553.May 27 2022, 7:20 AM

NFC update

amyk added inline comments.May 30 2022, 8:58 PM
clang/include/clang/Basic/DiagnosticSemaKinds.td
7572
clang/lib/Sema/SemaOverload.cpp
1664

Just wanted to check, but is this case covered in the comment above? If it is not, can we add a comment for it?

13026

Unnecessary change?

maryammo updated this revision to Diff 437161.Jun 15 2022, 7:28 AM

Tune the logic to emit warning when at least one of the vectors is altivec one and overloading resolution is done

amyk added a comment.Jun 15 2022, 10:02 AM

Some additional minor comments.

clang/include/clang/Basic/DiagnosticSemaKinds.td
7572

nit: Update to

The default behaviour will change to what is implied by the

clang/lib/Sema/SemaExpr.cpp
7715

Can we add some brief documentation for this function, like what is done for other functions in this file?

7716

Can we add a message to this assert()?

7722

nit: Can we put braces on the same line? (And same goes for 7727)

7735

Can we add some brief documentation for this function, like what is done for other functions in this file?

7736

Can we add a message to this assert?

7762

Unnecessary change?

clang/lib/Sema/SemaOverload.cpp
13026

Unnecessary change?

lei added a comment.Jun 15 2022, 10:46 AM

Please document all new functions added.

clang/lib/Sema/SemaExpr.cpp
7715

feels like this should be written to just take either 1 param or multiple params via vararg.. since the 2 arg are not really related in any way.

9565

clang-format

10520

clang-format

maryammo added inline comments.Jun 15 2022, 10:48 AM
clang/lib/Sema/SemaExpr.cpp
7715

sure

7716

I followed what was done for other similar functions like : areMatrixTypesOfTheSameDimension

7716

same as others

7722

sure

7735

sure

7736

I followed what was done for other similar functions like : areMatrixTypesOfTheSameDimension

clang/lib/Sema/SemaOverload.cpp
13026

yes

maryammo added inline comments.Jun 15 2022, 11:03 AM
clang/lib/Sema/SemaExpr.cpp
7715

I am not sure what you mean, can you please elaborate on that?

maryammo updated this revision to Diff 437303.Jun 15 2022, 12:53 PM
maryammo marked an inline comment as not done.

Address the review comments

maryammo updated this revision to Diff 437313.Jun 15 2022, 1:12 PM

clang-format

maryammo updated this revision to Diff 437317.Jun 15 2022, 1:27 PM

Fixing unintentional merge from previous commit

amyk accepted this revision.Jun 15 2022, 4:44 PM

Thanks for the updates. Unless @lei has any other additional comments, I think LGTM.

This revision is now accepted and ready to land.Jun 15 2022, 4:44 PM
lei added a comment.Jun 15 2022, 7:37 PM

LGTM, just a few nit that can be addressed on commit.

clang/lib/Sema/SemaExpr.cpp
7715

actually ignore that comment. I see why you need this now.

7723

do we really need this check since we have an assert above?

7726

I don't think the initialization above is needed. Can just inline it here.

bool  isSrcTyAltivec = (SrcVecKind == VectorType::AltiVecVector);
7728

same.

7731

same.

maryammo added inline comments.Jun 15 2022, 8:12 PM
clang/lib/Sema/SemaExpr.cpp
7723

Yes, without this check there is gonna be a compile time failure for cases where SrcTy is not vector but we wanna cast it to vector 'SrcTy->castAs<VectorType>()'

maryammo added inline comments.Jun 15 2022, 8:21 PM
clang/lib/Sema/SemaExpr.cpp
7723

the assert checks of either of them is a vector but then we wanna check if at least one of them is altivec.

lei added inline comments.Jun 16 2022, 5:40 AM
clang/lib/Sema/SemaExpr.cpp
7716

maybe rename to anyAltivecTypes()?

7738

rename suggestion: haveSameVectorElemTypes()

lei added inline comments.Jun 16 2022, 5:44 AM
clang/lib/Sema/SemaExpr.cpp
7738

rename suggestion: haveSameVectorElemTypes()

actually maybe this: areSameVectorElemTypes()

nemanjai added inline comments.Jun 16 2022, 2:25 PM
clang/include/clang/Basic/DiagnosticSemaKinds.td
7571–7573

We should not mention the word bitcast in the message as it doesn't really mean anything to C/C++ developers not used to LLVM IR.
We can make the text something like:

Implicit conversion between vector types ('%0' and '%1') is deprecated. In the future, the behavior implied by '-fno-lax-vector-conversions' will be the default.
clang/lib/Sema/SemaExpr.cpp
7718

The message does not need to mention the function name. Something like
"expected at least one type to be a vector here" should suffice.

7720

Nit: naming convention. Here and elsewhere - please review all of your variable names.

7723–7727

I think the whole thing can simply be:

bool IsSrcTyAltivec = SrcTy->isVectorType() &&
  (SrcTy->castAs<VectorType>()->getVectorKind() == VectorType::AltiVecVector);

And similarly for the destination type.

7740

Similarly to my comment above regarding the assert message.

9564

Please add a comment:

// The default for lax vector conversions with Altivec vectors will
// change, so if we are converting between vector types where
// at least one is an Altivec vector, emit a warning.
maryammo updated this revision to Diff 437740.Jun 16 2022, 3:47 PM

Address review comments

This revision was landed with ongoing or failed builds.Jun 16 2022, 6:28 PM
This revision was automatically updated to reflect the committed changes.