aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/ModuloSchedule.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-09-29 09:43:52 -0700
committerGitHub <noreply@github.com>2025-09-29 09:43:52 -0700
commit3e54505b439923a34fe5cbf27743d883fb62ad9f (patch)
tree0b1e11d5a511db5114d80a18c9abff8485af196b /llvm/lib/CodeGen/ModuloSchedule.cpp
parent2dd743187655261815a95477d3956051e7cf5b04 (diff)
downloadllvm-3e54505b439923a34fe5cbf27743d883fb62ad9f.zip
llvm-3e54505b439923a34fe5cbf27743d883fb62ad9f.tar.gz
llvm-3e54505b439923a34fe5cbf27743d883fb62ad9f.tar.bz2
[ADT] Fix a bug in EquivalenceClasses::erase (#161121)
This patch fixes a bug in EquivalenceClasses::erase, where we lose a leader bit in a certain scenario. Here is some background. In EquivalenceClasses, each equivalence class is maintained as a singly linked list over its members. When we join two classes, we concatenate the two singly linked lists. To support path compression, each member points to the leader (through lazy updates). This is implemented with the two members: class ECValue { mutable const ECValue *Leader, *Next; : }; Each member stores its leader in Leader and its sibling in Next. Now, the leader uses the Leader field to to point the last element of the singly linked list to accommodate the list concatenation. We use the LSB of the Next field to indicate whether a given member is a leader or not. Now, imagine we have an equivalence class: Elem 1 -> Elem 2 -> nullptr Leader and wish to remove Elem 2. We would like to end up with: Elem 1 -> nullptr Leader but we mistakenly drop the leader bit when we update the Next field of Elem 1 with: Pre->Next = nullptr; This makes Elem 1 the end of the singly linked list, as intended, but mistakenly clears its leader bit stored in the LSB of Next, so we end up with an equivalence class with no leader. This patch fixes the problem by preserving the leader bit: Pre->Next = reinterpret_cast<const ECValue *>( static_cast<intptr_t>(Pre->isLeader())); The unit test closely follows the scenario above.
Diffstat (limited to 'llvm/lib/CodeGen/ModuloSchedule.cpp')
0 files changed, 0 insertions, 0 deletions