Skip to content

Commit 7156bcf

Browse files
authored
[Attributor][FIX] Ensure we do not use stale references (#104495)
When copying map entries, we might run into resizing and invalidate the RHS of the assignment. We dealt with this before and now use the proper helper to avoid the problem in another place. Fixes: #104397
1 parent c5b611a commit 7156bcf

File tree

2 files changed

+593
-2
lines changed

2 files changed

+593
-2
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,8 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
16281628
<< "\n");
16291629
assert(OffsetInfoMap.count(CurPtr) &&
16301630
"The current pointer offset should have been seeded!");
1631+
assert(!OffsetInfoMap[CurPtr].isUnassigned() &&
1632+
"Current pointer should be assigned");
16311633

16321634
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Usr)) {
16331635
if (CE->isCast())
@@ -1906,6 +1908,7 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
19061908
};
19071909
auto EquivalentUseCB = [&](const Use &OldU, const Use &NewU) {
19081910
assert(OffsetInfoMap.count(OldU) && "Old use should be known already!");
1911+
assert(!OffsetInfoMap[OldU].isUnassigned() && "Old use should be assinged");
19091912
if (OffsetInfoMap.count(NewU)) {
19101913
LLVM_DEBUG({
19111914
if (!(OffsetInfoMap[NewU] == OffsetInfoMap[OldU])) {
@@ -1916,8 +1919,8 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
19161919
});
19171920
return OffsetInfoMap[NewU] == OffsetInfoMap[OldU];
19181921
}
1919-
OffsetInfoMap[NewU] = OffsetInfoMap[OldU];
1920-
return true;
1922+
bool Unused;
1923+
return HandlePassthroughUser(NewU.get(), OldU.get(), Unused);
19211924
};
19221925
if (!A.checkForAllUses(UsePred, *this, AssociatedValue,
19231926
/* CheckBBLivenessOnly */ true, DepClassTy::OPTIONAL,

0 commit comments

Comments
 (0)