It is legal for the type passed to isLegalAddressingMode to be unsized or, more specifically, VoidTy. In this case, we must check the legality of load / stores for all legal types. Directly trying to call getTypeStoreSize is incorrect, and leads to breakage in e.g. Loop Strength Reduction. This change guards against that behaviour.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
679 | I would prefer to exit earlier than this. It is not address space specific and we hardly can do anything good on a void or opaque type. |
lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
679 | ... but then it crashes another couple of tests. We seems to be required to process that LSR formulae. |
I believe that we need to behave as is LegalAddressingMode is supposed to behave in general(see 469 in TargetTransformInfo.h):
/// Return true if the addressing mode represented by AM is legal for /// this target, for a load/store of the specified type. /// The type may be VoidTy, in which case only return true if the addressing /// mode is legal for a load/store of any legal type. /// If target returns true in LSRWithInstrQueries(), I may be valid.
When I looked at it, it was the case that VoidTy is essentially a tag type in this case. Other targets such as AArch64 also acknowledge that an unsized type may be passed through all the way to isLegalAddressingMode.
You should only change the test if the original problem shows up. You should be able to coax it into failing with just opt though (maybe you need to run more passes before LSR on it?)
Test is not changed, just moved. Note that many of our lsr tests there use llc to run. I was unable to make it reproducible with opt given any pass set. If one wants to run it with opt it will probably require a different test.
I would prefer to exit earlier than this. It is not address space specific and we hardly can do anything good on a void or opaque type.