[all-commits] [llvm/llvm-project] aa9772: [SCCP] Avoid modifying AdditionalUsers while itera...

Dimitry Andric via All-commits all-commits at lists.llvm.org
Tue May 11 17:30:16 PDT 2021


  Branch: refs/heads/release/12.x
  Home:   https://github.com/llvm/llvm-project
  Commit: aa97726f6040c68dfdd8076e8efe3ef119f6b037
      https://github.com/llvm/llvm-project/commit/aa97726f6040c68dfdd8076e8efe3ef119f6b037
  Author: Dimitry Andric <dimitry at andric.com>
  Date:   2021-05-11 (Tue, 11 May 2021)

  Changed paths:
    M llvm/lib/Transforms/Scalar/SCCP.cpp
    A llvm/test/Transforms/SCCP/pr49582-iterator-invalidation.ll

  Log Message:
  -----------
  [SCCP] Avoid modifying AdditionalUsers while iterating over it

When run under valgrind, or with a malloc that poisons freed memory,
this can lead to segfaults or other problems.

To avoid modifying the AdditionalUsers DenseMap while still iterating,
save the instructions to be notified in a separate SmallPtrSet, and use
this to later call OperandChangedState on each instruction.

Fixes PR49582.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D98602

(cherry picked from commit 6abb92f2103a58d097620b4410054c5bb18c48ec)




More information about the All-commits mailing list