[all-commits] [llvm/llvm-project] ed193b: [mlir][Vector][Affine] Fix heap-use-after-free in ...

Diego Caballero via All-commits all-commits at lists.llvm.org
Thu Mar 11 10:51:20 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ed193bce9d3bf8ebfe7f0c30045fc5964912074d
      https://github.com/llvm/llvm-project/commit/ed193bce9d3bf8ebfe7f0c30045fc5964912074d
  Author: Diego Caballero <diego.caballero at intel.com>
  Date:   2021-03-11 (Thu, 11 Mar 2021)

  Changed paths:
    M mlir/include/mlir/Analysis/NestedMatcher.h
    M mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp

  Log Message:
  -----------
  [mlir][Vector][Affine] Fix heap-use-after-free in vectorizer

This patch fixes a heap-use-after-free introduced by the recent changes
in the vectorizer: https://reviews.llvm.org/rG95db7b4aeaad590f37720898e339a6d54313422f
The problem is due to the way candidate loops are visited. All candidate loops
are pattern-matched beforehand using the 'NestedMatch' utility. These matches may
intersect with each other so it may happen that we try to vectorize a loop that
was previously vectorized. The new vectorization algorithm replaces the original
loops that are vectorized with new loops and, therefore, any reference to the
original loops in the pre-computed matches becomes invalid.

This patch fixes the problem by classifying the candidate matches into buckets
before vectorization. Each bucket contains all the matches that intersect. The
vectorizer uses these buckets to make sure that we only vectorize *one* match from
each bucket, at most.

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




More information about the All-commits mailing list