Skip to content

Commit cb98c62

Browse files
committed
[Attributor] Fix an issue that could potentially cause AccessList and OffsetBins out of sync
The implementation of `AAPointerInfo::RangeList::set_difference` doesn't consider the case where two ranges have the same offset but different sizes. This could causes `AccessList` and `OffsetBins` out of sync because a range has been already updated in `AccessList` but missing in `ToRemove`. I do have a reproducer but the reproducer itself is 248kb. `llvm-reduce` can't further reduce it. Not sure how I can make a smaller reproducer. Fix SWDEV-479757.
1 parent 78505ad commit cb98c62

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5817,8 +5817,12 @@ struct AAPointerInfo : public AbstractAttribute {
58175817
/// Copy ranges from \p L that are not in \p R, into \p D.
58185818
static void set_difference(const RangeList &L, const RangeList &R,
58195819
RangeList &D) {
5820-
std::set_difference(L.begin(), L.end(), R.begin(), R.end(),
5821-
std::back_inserter(D), RangeTy::OffsetLessThan);
5820+
std::set_difference(
5821+
L.begin(), L.end(), R.begin(), R.end(), std::back_inserter(D),
5822+
[](const RangeTy &L, const RangeTy &R) {
5823+
return (L.Offset < R.Offset) ||
5824+
((L.Offset == R.Offset) && (L.Size != R.Size));
5825+
});
58225826
}
58235827

58245828
unsigned size() const { return Ranges.size(); }

0 commit comments

Comments
 (0)