This is an archive of the discontinued LLVM Phabricator instance.

Bug 20557 - bogus cpu parameter crashes llc
ClosedPublic

Authored by iid_iunknown on Aug 22 2014, 1:38 AM.

Details

Reviewers
HaoLiu
Summary

Hi Hao,

Would you be able to find some time and review this simple correction that we discussed previously, please?
Thank you.

Problem summary:

Regression caused by http://reviews.llvm.org/D4322.
Llc crashes when compiling the attached file if -march=aarch64 and -mcpu specifies a cpu that is invalid for this architecture.

The problem is with v1f32 type. According to AArch64TargetLowering::getPreferredVectorAction this vector type should be widened on aarch64.

If a bogus CPU is passed to llc, v2f32 is not added to the legal types list.
Because of that, v1f32 fails to be widened, so TargetLoweringBase::computeRegisterProperties() falls through to the next switch-case branch, which sets the preferred type action to TypeSplitVector. This means we are trying to split one element vector. This triggers the assert in VectorType::get. The same applies to other 1-sized vector types listed in getPreferredVectorAction: v1i8, v1i16 and v1i32.

Fix summary:

If the preferred action for a one element vector is neither TypeSplitVector nor TypeScalarizeVector and it fails to be applied, then the action is set to TypeScalarizeVector instead of TypeSplitVector.

Diff Detail

Event Timeline

iid_iunknown retitled this revision from to Bug 20557 - bogus cpu parameter crashes llc.
iid_iunknown updated this object.
iid_iunknown edited the test plan for this revision. (Show Details)
iid_iunknown added a reviewer: HaoLiu.
iid_iunknown set the repository for this revision to rL LLVM.
iid_iunknown added a subscriber: Unknown Object (MLST).
HaoLiu edited edge metadata.Oct 20 2014, 6:40 PM

Hi Oleg,

I'm very sorry that I missed this message for such a long time.

I think your solution is reasonable. But it looks somehow misleading. People don't know what is the current PreferredAction. So I think we'd better use more if and else as following:

if (PreferredAction == TypeSplitVector)
  setTypeAction TypeSplitVector 
else if (PreferredAction == TypeScalarizeVector)
   setTypeAction TypeScalarizeVector 
else
   // when the preferred action is neither TypeSplitVector nor TypeScalarizeVector
  NElts == 1 ? TypeScalarizeVector : TypeSplitVector

I just think this is more clear.

Thanks,
-Hao

HaoLiu accepted this revision.Oct 30 2014, 11:33 PM
HaoLiu edited edge metadata.
This revision is now accepted and ready to land.Oct 30 2014, 11:33 PM
HaoLiu closed this revision.Oct 30 2014, 11:33 PM