Skip to content

Commit 8fab223

Browse files
Fix intermittent error bounds inference (fix #585) (#589)
Iterate over a BoundsKey set instead of a ProgramVar* set so that the iteration order does not depend on the address of the program variables. This fixes the issue, but it is still potentially a problem that the function depends on the order it iterations over the bounds keys. It is also likely that other loops over sets of pointers exbibit this same problem.
1 parent 9415bf4 commit 8fab223

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

clang/lib/3C/AVarBoundsInfo.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,15 @@ void
129129
AvarBoundsInference::
130130
mergeReachableProgramVars(BoundsKey TarBK, std::set<BoundsKey> &AllVars) {
131131
if (AllVars.size() > 1) {
132-
// Convert the bounds key to corresponding program var.
133-
std::set<ProgramVar *> AllProgVars;
134-
for (auto AV : AllVars) {
135-
AllProgVars.insert(BI->getProgramVar(AV));
136-
}
137132
ProgramVar *BVar = nullptr;
138133
bool IsTarNTArr = BI->NtArrPointerBoundsKey.find(TarBK) !=
139134
BI->NtArrPointerBoundsKey.end();
140135
// We want to merge all bounds vars. We give preference to
141136
// non-constants if there are multiple non-constant variables,
142137
// we give up.
143-
for (auto *TmpB : AllProgVars) {
138+
for (auto TmpBKey : AllVars) {
139+
// Convert the bounds key to corresponding program var.
140+
auto *TmpB = BI->getProgramVar(TmpBKey);
144141
// First case.
145142
if (BVar == nullptr) {
146143
BVar = TmpB;

0 commit comments

Comments
 (0)