This fixes crashing on auto *VT = cast<FixedVectorType>(DataTy); when
the type is a scalable vector.
Details
- Reviewers
sdesmalen
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
The crash only triggered target is given (specify -mtriple=riscv64) and BasicTTIImplBase::getCommonMaskedMemoryOpCost would be called.
If no target given, NoTTIImpl is used as TTI, and TargetTransformInfoImpl.h::getMemoryOpCost simply returns cost 1 without any crash.
I don't have plan to implement hook getMaskedMemoryOpCost for RISCV.
Do you have any suggest for this kind situation?
This function assumes fixed-width vectors and cannot be used for scalable vectors. I'm not sure what returning 'Invalid' here would really fix, other than the compiler not crashing for a use-case that should not have occurred in the first place, because an overloaded cost function should have been implemented. Whether the compiler falls into the assert from cast<FixedVectorType>, or whether it returns an Invalid cost, in either case you'll need to implement a memory-op-cost function for your target. And because you'll need to implement a cost-function anyway, returning Invalid doesn't really make a difference, because then this code will never be hit. Otherwise, you would have been able to write a test-case for it.
This function assumes fixed-width vectors and cannot be used for scalable vectors. I'm not sure what returning 'Invalid' here would really fix, other than the compiler not crashing for a use-case that should not have occurred in the first place, because an overloaded cost function should have been implemented. Whether the compiler falls into the assert from cast<FixedVectorType>, or whether it returns an Invalid cost, in either case you'll need to implement a memory-op-cost function for your target. And because you'll need to implement a cost-function anyway, returning Invalid doesn't really make a difference, because then this code will never be hit. Otherwise, you would have been able to write a test-case for it.
Many salable vectors use this function and crash . Maybe D121677 is a test-case. GetMaskedMemoryOpCost and getGatherScatterOpCost only return getCommonMaskedMemoryOpCost , so each scalable vector call to these functions will crash. However, getMaskedMemoryOpCost and getGatherScatterOpCost can be implemented by each target, not implemented will it crashes. There seems to be a problem.