This seems to only work some of the time. In some situations,
this seems to use a nonsensical type and isn't actually aware of the
memory being accessed. e.g. if branch condition is an icmp of a pointer,
it checks the addressing mode of i1.
Details
- Reviewers
hfinkel
Diff Detail
Event Timeline
Would it be better to do this refactoring by making some pair<Type *, AddressSpace> and passing that around instead of adding the extra AddressSpace parameter everywhere? If the underlying premise is that the Type is meaningless without the address space, I'd prefer to just force them to live together.
lib/Transforms/Scalar/LoopStrengthReduce.cpp | ||
---|---|---|
3180 | I'd rather not end up with code like this. It would be better to define some global constant InvalidAddressSpace (or similar) that is equal to ~0u, and then use that. |
lib/Transforms/Scalar/LoopStrengthReduce.cpp | ||
---|---|---|
3180 | Where should this be defined? I'm not sure where would be a good place for it |
lib/Transforms/Scalar/LoopStrengthReduce.cpp | ||
---|---|---|
106 | There's no need for this to be a pre-processor macro, we can say: static const unsigned UnknownAddressSpace = ~0u; and make it a member of MemAccessTy. Also, please comment that this is used to initialize the AddressSpace member of MemAccessTy, for non-pointer types, but that ~0u is actually a legal address space value (unless we want to change that, but that requires updating the AsmParser, etc.). | |
3180 | MemAccessTy(nullptr, UNKNOWN_ADDRESS_SPACE) -> MemAccessTy() (or do you want MemAccessTy::getUnknown()?) |
lib/Transforms/Scalar/LoopStrengthReduce.cpp | ||
---|---|---|
106 | Is there some header where this should go? There are a few other places that call isLegalAddressingMode in other passes where it's unclear what the address space would mean. Address spaces > 24 bits are already disallowed by the code in other places although I'm not sure this is documented anywhere. |
lib/Transforms/Scalar/LoopStrengthReduce.cpp | ||
---|---|---|
3180 | This is nullptr because this is what it was using previously for the type. The existing code in some places uses void type and others use nullptr, and I'm not sure if there's a significant distinction between the uses. Changing this should be a separate change if worth doing |
There's no need for this to be a pre-processor macro, we can say:
and make it a member of MemAccessTy.
Also, please comment that this is used to initialize the AddressSpace member of MemAccessTy, for non-pointer types, but that ~0u is actually a legal address space value (unless we want to change that, but that requires updating the AsmParser, etc.).