Clean up of the code of Loop Versioning for LICM. See comments to the changes below.
Details
Diff Detail
- Build Status
Buildable 419 Build 419: arc lint + arc unit
Event Timeline
lib/Transforms/Scalar/LoopVersioningLICM.cpp | ||
---|---|---|
161 | TargetLibraryInfo is not used in the code. | |
169 | Removed unused fields or made them function scoped instead of class scoped. | |
173 | Made internal data private. | |
305 | It's strange checking. It was questioned in https://reviews.llvm.org/D9151. An answer was:
Yes, type checking is needed for AliasSet when all pointers must alias. This is done by LICM. In case of AliasSet whose pointers may alias we can have aliased pointers of different types, e.g. char * and char ** which might be aliased and they have different types. | |
510 | Converted to be function scoped. | |
512 | Converted to be function scoped. | |
515 | Converted to be function scoped. | |
515–516 | Removed as unused. | |
522 | Removed as unused. | |
524 | This is not safe. Replaced with unique_ptr. | |
567 | Removed as unused. |
lib/Transforms/Scalar/LoopVersioningLICM.cpp | ||
---|---|---|
305 | I agree, this does look strange (and it might not be a NFC), I think either Ashutosh or Adam should comment on this. | |
524 | Why is this not safe? It looks like if we don't use use unique_ptr we end up with less memory usage (unique_ptr won't free the memory until LoopVersioningLICMs destructor gets called or until we run on another loop). |
lib/Transforms/Scalar/LoopVersioningLICM.cpp | ||
---|---|---|
305 | Yes, it is required but LICM does it for alias sets with must-alias pointers. Here an alias set with may-alias pointers is checked. The goal of the LoopVersioningLICM pass is to create a version of a loop where all alias sets with may-alias pointers are converted either into sets with must-alias pointers or single-element sets. The checking is similar to what LICM does but it has different meaning. It restricts may-alias pointers used in a loop to have the same type. It excludes a case when 'char *' pointer can be aliased with everything. For example the following loop is not versioned because of this checking: void f(int *a, int *b, char *c, int n) { for (int i = 0; i < n; ++i) { a[i] = b[i] + *c; *c = (char)a[i]; } } In this case an alias set consists of 'a', 'b' and 'c'. We can calculate bounds of all pointers used in the loop. So we can create RT checks and move memory accesses to 'c' out of the loop. |
LGTM
lib/Transforms/Scalar/LoopVersioningLICM.cpp | ||
---|---|---|
522 | Ok, Evgeny just explained to me that this would release the memory when it goes out of scope. I think it's fine now. |
TargetLibraryInfo is not used in the code.